home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume6 / glib / part03 < prev    next >
Encoding:
Text File  |  1989-05-14  |  57.2 KB  |  2,927 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v06i104: glib part 3 of 15
  4. Reply-To: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  5.  
  6. Posting-number: Volume 6, Issue 104
  7. Submitted-by: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  8. Archive-name: glib/part03
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 3 (of 15)."
  17. # Contents:  d10rsu.mnu d10ton.c glib.1 k1vis.c mac-mach.c tx81z.mnu
  18. #   unix-mach.c
  19. # Wrapped by lee@uhccux on Sun May  7 00:40:10 1989
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'd10rsu.mnu' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'d10rsu.mnu'\"
  23. else
  24. echo shar: Extracting \"'d10rsu.mnu'\" \(8147 characters\)
  25. sed "s/^X//" >'d10rsu.mnu' <<'END_OF_FILE'
  26. X/* $Id: d10rsu.mnu,v 1.6 89/05/06 17:13:15 lee Exp $
  27. X * GLIB - a Generic LIBrarian and editor for synths
  28. X *
  29. X * D10 Rhythm Setup Librarian
  30. X *
  31. X * Code started 1 FEB 89 --  Michael R. Kesti mrk@gvgspd.GVG.TEK.COM
  32. X * modified by Greg Lee
  33. X * $Log:    d10rsu.mnu,v $
  34. X * Revision 1.6  89/05/06  17:13:15  lee
  35. X * rel. to comp.sources.misc
  36. X * 
  37. X */
  38. X
  39. X#include "glib.h"
  40. X#include "vis.h"
  41. X
  42. X#define D10RSUSIZE 4
  43. X#define RSUBASEADDR 0x090000
  44. X#define RESERVESIZE 20
  45. X
  46. Xchar *visnum(), *visonoff();
  47. X
  48. X
  49. X/* This array contains arbitrary screen labels */
  50. Xstruct labelinfo Ldrsu[] = {
  51. X#MENU
  52. X
  53. X
  54. X
  55. X
  56. X
  57. X
  58. X
  59. X
  60. X                         Tone Select     %
  61. X                         Level           %
  62. X                         Pan             %
  63. X                         Reverb Switch   %
  64. X
  65. X
  66. X
  67. X
  68. X
  69. X
  70. X
  71. X
  72. X
  73. X
  74. X
  75. X Press SPACE BAR to sound note %   at volume %   for duration %  on channel % .
  76. X#END
  77. X-1,-1,NULL
  78. X};
  79. X
  80. Xstruct paraminfo  Pdrsu[] =  {
  81. X/*
  82. XNAME        TYPE        POS    MAX    OFFSET    MASK    SHIFT    ADHOC
  83. X */
  84. X#O tone        rtone        %%    127    0
  85. X#O level    patchlevel    %%    100    1
  86. X#O pan        pan        %%    14    2
  87. X#O reverbsw    onoff        %%    1    3
  88. X#O autopitch    num        %%    127    -60
  89. X#O autovol    num        %%    127    -63
  90. X#O autodur    num        %%    20    -5    *5
  91. X#O autochan    num        %%    16    -1    *5
  92. XNULL,NULL,-1,-1,-1,-1,visnum,0,0,0,0
  93. X};
  94. X
  95. X/*
  96. X * drsunum
  97. X *
  98. X * Convert a voice number (0 to 84) to the string displayed in the
  99. X * librarian (ie. 01 to 85).
  100. X */
  101. X
  102. Xchar *
  103. Xdrsunum(n)
  104. X{
  105. X    static char v[3];
  106. X
  107. X    sprintf(v, "%02d", n + 1);
  108. X    return(v);
  109. X}
  110. X
  111. X/*
  112. X * dnumrsu
  113. X *
  114. X * Convert a display-style voice number (01 to 85) to internal
  115. X * format (0 to 84).
  116. X */
  117. X
  118. Xdnumrsu(n)
  119. Xint n;
  120. X{
  121. X    return(n-1);
  122. X}
  123. X
  124. X/*
  125. X * drsudin
  126. X *
  127. X * Take library bank 'data' and stuff values in the P array, by using
  128. X * the setval function.
  129. X */
  130. X
  131. Xdrsudin(data)
  132. Xchar *data;
  133. X{
  134. X    /* The first RESERVESIZE bytes are reserved (arbitrarily) for the voice name */
  135. X#SETVAL
  136. X}
  137. X
  138. X/*
  139. X * drsudout
  140. X *
  141. X * Take (possibly changed) parameters values out of the P array and
  142. X * put them back into the library bank 'data'.
  143. X */
  144. X
  145. Xdrsudout(data)
  146. Xchar *data;
  147. X{
  148. X#GETVAL
  149. X}
  150. X
  151. X/*
  152. X * drsusedit
  153. X *
  154. X * Send a single voice to the edit buffer of the D10.  This will be whatever
  155. X * voice is currently selected.
  156. X */
  157. X
  158. Xdrsusedit(data)
  159. Xchar *data;
  160. X{
  161. X    int n;
  162. X    int cksum;
  163. X    
  164. X    sendmidi(0xf0);
  165. X    sendmidi(0x41);
  166. X    sendmidi(0x10);
  167. X    sendmidi(0x16);
  168. X    sendmidi(0x12);        /* DT1 - Data set 1 command */
  169. X    sendmidi(0x03);        /* address msb */
  170. X    cksum = 0x03;
  171. X    sendmidi(0x01);
  172. X    cksum += 0x01;
  173. X    sendmidi(0x10);        /* address lsb */
  174. X    cksum += 0x10;
  175. X    for(n = 0; n < D10RSUSIZE; n++) {
  176. X        sendmidi(data[n + RESERVESIZE] & 0x7f);
  177. X        cksum += data[n + RESERVESIZE] & 0x7f;
  178. X    }
  179. X    sendmidi((-cksum) & 0x7f);    /* checksum */
  180. X    sendmidi(EOX);
  181. X}
  182. X
  183. X/*
  184. X * drsunof
  185. X *
  186. X * Return a pointer to the voice name buried in library bank data.
  187. X */
  188. Xchar *
  189. Xdrsunof(data)
  190. Xchar *data;
  191. X{
  192. X
  193. X    static char buf[4];
  194. X    int n;
  195. X
  196. X    for(n = 0; n < D10RSUSIZE; n++)
  197. X        if ( data[n + RESERVESIZE] != 0 ) break;
  198. X    if ( n != D10RSUSIZE ) {
  199. X        strcpy(buf, visrtone(data[RESERVESIZE + 0]));
  200. X    } else
  201. X        strcpy(buf, "   ");
  202. X
  203. X    return(buf);
  204. X}
  205. X
  206. X/*
  207. X * drsusnof
  208. X *
  209. X * Set the voice name buried in data to name.
  210. X */
  211. Xdrsusnof(data,name)
  212. Xchar *data;
  213. Xchar *name;
  214. X{
  215. X}
  216. X
  217. X/* drsusone - send a single voice to the D10 */
  218. Xdrsusone(iv, data)
  219. Xint iv;
  220. Xchar *data;
  221. X{
  222. X    int n;
  223. X    int cksum;
  224. X    long curadd;
  225. X    int addbyte;
  226. X
  227. X    curadd = RSUBASEADDR;
  228. X
  229. X    for(n = 0; n < iv; n++) {
  230. X        curadd += D10RSUSIZE;
  231. X        if((curadd & 0x80) != 0) {
  232. X            curadd &= 0x7fff7f;
  233. X            curadd += 0x100;
  234. X        }
  235. X        if((curadd & 0x8000) != 0) {
  236. X            curadd &= 0x7f7f7f;
  237. X            curadd += 0x10000;
  238. X        }
  239. X    }
  240. X
  241. X    sendmidi(0xf0);
  242. X    sendmidi(0x41);
  243. X    sendmidi(0x10);
  244. X    sendmidi(0x16);
  245. X    sendmidi(0x12);        /* DT1 - Data set 1 command */
  246. X    addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  247. X    sendmidi(addbyte);
  248. X    cksum = addbyte;
  249. X    addbyte = ((curadd >> 8) & 0x7f);
  250. X    sendmidi(addbyte);
  251. X    cksum += addbyte;
  252. X    addbyte = (curadd & 0x7f);        /* address lsb */
  253. X    sendmidi(addbyte);
  254. X    cksum += addbyte;
  255. X    for(n = 0; n < D10RSUSIZE; n++) {
  256. X        sendmidi(data[n + RESERVESIZE] & 0x7f);
  257. X        cksum += data[n + RESERVESIZE] & 0x7f;
  258. X    }
  259. X    sendmidi((-cksum) & 0x7f);    /* checksum */
  260. X    sendmidi(EOX);
  261. X
  262. X    return(0);
  263. X}
  264. X
  265. X/* drsugbulk - Request and read a bulk dump from the D10 */
  266. Xdrsugbulk(data)
  267. Xchar *data;
  268. X{
  269. X    static    char Buff[BUFSIZ];
  270. X    int n, v, b2, ret = 1;
  271. X    long begin, toolong;
  272. X    long curadd;
  273. X    int addbyte;
  274. X    int cksum;
  275. X    
  276. X    sprintf(Buff,"\n");
  277. X    windstr(Buff);
  278. X
  279. X    curadd = RSUBASEADDR;
  280. X
  281. X    for(v = 0; v < Nvoices; v++) {
  282. X
  283. X        flushmidi();
  284. X
  285. X        if((v % 10) != 0) {
  286. X            sprintf(Buff, ".");
  287. X        } else {
  288. X            sprintf(Buff,"%d", (v / 10));
  289. X        }
  290. X        windstr(Buff);
  291. X
  292. X    /* request the voice */
  293. X        sendmidi(0xf0);
  294. X        sendmidi(0x41);
  295. X        sendmidi(0x10);
  296. X        sendmidi(0x16);
  297. X        sendmidi(0x11);        /* RQ1 - Data request 1 command */
  298. X
  299. X        addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  300. X        sendmidi(addbyte);
  301. X        cksum = addbyte;
  302. X        addbyte = ((curadd >> 8) & 0x7f);
  303. X        sendmidi(addbyte);
  304. X        cksum += addbyte;
  305. X        addbyte = (curadd & 0x7f);        /* address lsb */
  306. X        sendmidi(addbyte);
  307. X        cksum += addbyte;
  308. X
  309. X        sendmidi(0x00);        /* length msb */
  310. X        cksum += 0x00;
  311. X        sendmidi(0x00);
  312. X        cksum += 0x00;
  313. X        sendmidi(D10RSUSIZE);    /* length lsb */
  314. X        cksum += D10RSUSIZE;
  315. X
  316. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  317. X        sendmidi(EOX);
  318. X    
  319. X    /* set up timeout */
  320. X        begin = milliclock();
  321. X        toolong = begin + (1000 * TIMEOUT);
  322. X    
  323. X    /* read header */
  324. X        for(n = 0; n < 8; ) {
  325. X            if ( STATMIDI ) {
  326. X                b2 = (getmidi() & 0xff);
  327. X                /* burn active sensing and timing clock */
  328. X                if((b2 != 0xfe) && (b2 != 0xf8))
  329. X                    n++;
  330. X            } else {
  331. X                if ( milliclock() > toolong ) {
  332. X                    Reason = "Timeout waiting for header";
  333. X                    goto getout;
  334. X                }
  335. X            }
  336. X        }
  337. X
  338. X    /* read data */
  339. X        for(n = 0; n < D10RSUSIZE; ) {
  340. X            if ( STATMIDI ) {
  341. X                b2 = (getmidi() & 0xff);
  342. X                /* burn active sensing and timing clock */
  343. X                if((b2 != 0xfe) && (b2 != 0xf8)) {
  344. X                    VOICEBYTE(data,v,n + RESERVESIZE) = b2;
  345. X                    n++;
  346. X                }
  347. X            } else {
  348. X                if ( milliclock() > toolong ) {
  349. X                    Reason = "Timeout reading data";
  350. X                    goto timeout;
  351. X                }
  352. X            }
  353. X        }
  354. X
  355. X    timeout:
  356. X        if ( n != D10RSUSIZE ) {
  357. X            Reason = "Timeout reading data!";
  358. X            goto getout;
  359. X        }
  360. X
  361. X    /* read checksum */
  362. X        for(n = 0; n < 1; ) {
  363. X            if ( STATMIDI ) {
  364. X                b2 = (getmidi() & 0xff);
  365. X                /* burn active sensing and timing clock */
  366. X                if((b2 != 0xfe) && (b2 != 0xf8))
  367. X                    n++;
  368. X            } else {
  369. X                if ( milliclock() > toolong ) {
  370. X                    Reason = "Timeout reading checksum";
  371. X                    goto getout;
  372. X                }
  373. X            }
  374. X        }
  375. X
  376. X    /* read EOX */
  377. X        for(n = 0; n < 1; ) {
  378. X            if ( STATMIDI ) {
  379. X                b2 = (getmidi() & 0xff);
  380. X                /* burn active sensing and timing clock */
  381. X                if((b2 != 0xfe) && (b2 != 0xf8))
  382. X                    if ( b2 != EOX ) {
  383. X                        sprintf(Buff,"EOX not received (%X)\n", b2);
  384. X                        Reason = Buff;
  385. X                        goto getout;
  386. X                    }
  387. X                    n++;
  388. X            } else {
  389. X                if ( milliclock() > toolong ) {
  390. X                    Reason = "Timeout reading EOX";
  391. X                    goto getout;
  392. X                }
  393. X            }
  394. X        }
  395. X
  396. X        curadd += D10RSUSIZE;
  397. X        if((curadd & 0x80) != 0) {
  398. X            curadd &= 0x7fff7f;
  399. X            curadd += 0x100;
  400. X        }
  401. X        if((curadd & 0x8000) != 0) {
  402. X            curadd &= 0x7f7f7f;
  403. X            curadd += 0x10000;
  404. X        }
  405. X
  406. X
  407. X    } /* go back for another voice */
  408. X
  409. X    Reason = "";
  410. X    ret = 0;    /* all's well */
  411. X
  412. Xgetout:
  413. X    return(ret);
  414. X}
  415. X
  416. X/* drsusbulk - send a bulk dump to the D10 */
  417. Xdrsusbulk(data)
  418. Xchar *data;
  419. X{
  420. X    static char Buff[BUFSIZ];
  421. X    int v, n;
  422. X    int cksum;
  423. X    long curadd;
  424. X    int addbyte, databyte;
  425. X    int curoff;
  426. X
  427. X    curadd = RSUBASEADDR;
  428. X    curoff = 0;    
  429. X    sprintf(Buff,"\n");
  430. X    windstr(Buff);
  431. X
  432. X    for(v = 0; v <Nvoices ; v++) {
  433. X        if((v % 10) != 0) {
  434. X            sprintf(Buff, ".");
  435. X        } else {
  436. X            sprintf(Buff,"%d", (v / 10));
  437. X        }
  438. X
  439. X        windstr(Buff);
  440. X        sendmidi(0xf0);
  441. X        sendmidi(0x41);
  442. X        sendmidi(0x10);
  443. X        sendmidi(0x16);
  444. X        sendmidi(0x12);        /* DT1 - Data set 1 command */
  445. X        addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  446. X        sendmidi(addbyte);
  447. X        cksum = addbyte;
  448. X        addbyte = ((curadd >> 8) & 0x7f);
  449. X        sendmidi(addbyte);
  450. X        cksum += addbyte;
  451. X        addbyte = (curadd & 0x7f);        /* address lsb */
  452. X        sendmidi(addbyte);
  453. X        cksum += addbyte;
  454. X
  455. X        for(n = 0; n < D10RSUSIZE; n++) {
  456. X            databyte = data[curoff + n + RESERVESIZE] & 0x7f;
  457. X            sendmidi(databyte);
  458. X            cksum += databyte;
  459. X        }
  460. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  461. X        sendmidi(EOX);
  462. X
  463. X        curadd += D10RSUSIZE;
  464. X        if((curadd & 0x80) != 0) {
  465. X            curadd &= 0x7fff7f;
  466. X            curadd += 0x100;
  467. X        }
  468. X        if((curadd & 0x8000) != 0) {
  469. X            curadd &= 0x7f7f7f;
  470. X            curadd += 0x10000;
  471. X        }
  472. X        curoff += (D10RSUSIZE + RESERVESIZE);
  473. X    }
  474. X    return(0);
  475. X}
  476. X
  477. X/* end */
  478. END_OF_FILE
  479. if test 8147 -ne `wc -c <'d10rsu.mnu'`; then
  480.     echo shar: \"'d10rsu.mnu'\" unpacked with wrong size!
  481. fi
  482. # end of 'd10rsu.mnu'
  483. fi
  484. if test -f 'd10ton.c' -a "${1}" != "-c" ; then 
  485.   echo shar: Will not clobber existing file \"'d10ton.c'\"
  486. else
  487. echo shar: Extracting \"'d10ton.c'\" \(7249 characters\)
  488. sed "s/^X//" >'d10ton.c' <<'END_OF_FILE'
  489. X/* $Id: d10ton.c,v 1.6 89/05/06 17:13:16 lee Exp $
  490. X * GLIB - a Generic LIBrarian and editor for synths
  491. X *
  492. X * D10 Tone Librarian Common Functions
  493. X *
  494. X * Code started 3 FEB 89 --  Michael R. Kesti mrk@gvgspd.GVG.TEK.COM
  495. X * $Log:    d10ton.c,v $
  496. X * Revision 1.6  89/05/06  17:13:16  lee
  497. X * rel. to comp.sources.misc
  498. X * 
  499. X */
  500. X
  501. X#include "glib.h"
  502. X
  503. X#define D10TONSIZE 246
  504. X#define TONBASEADDR 0x080000
  505. X#define RESERVESIZE 20
  506. X
  507. X/*
  508. X * dtonnum
  509. X *
  510. X * Convert a voice number (0 to 63) to the string displayed in the
  511. X * librarian (ie. 1 to 64).
  512. X */
  513. X
  514. Xchar *
  515. Xdtonnum(n)
  516. X{
  517. X    static char v[3];
  518. X
  519. X    if ( n < 0 || n > 63 )
  520. X        return("??");
  521. X
  522. X    v[0] = (n+1)/10 + '0';
  523. X    v[1] = (n+1)%10 + '0';
  524. X    v[2] = '\0';
  525. X    return(v);
  526. X}
  527. X
  528. X/*
  529. X * dnumton
  530. X *
  531. X * Convert a display-style voice number (1 to 64) to internal
  532. X * format (0 to 63).
  533. X */
  534. X
  535. Xdnumton(n)
  536. Xint n;
  537. X{
  538. X    int ld, rd;
  539. X    
  540. X    /* crack out the digits as decimal codes */
  541. X    ld = (n - 1) / 10; /* left digit */
  542. X    rd = (n - 1) % 10; /* right digit */
  543. X
  544. X    if(ld < 0 || ld > 6 || rd < 0 || rd > 9) {
  545. X        return(-1);
  546. X    } else {
  547. X        return(n - 1);
  548. X    }
  549. X}
  550. X/*
  551. X * dtonsedit
  552. X *
  553. X * Send a single voice to the edit buffer of the D10.  This will be whatever
  554. X * voice is currently selected.
  555. X */
  556. X
  557. Xdtonsedit(data)
  558. Xchar *data;
  559. X{
  560. X    int n;
  561. X    int cksum;
  562. X    
  563. X    sendmidi(0xf0);
  564. X    sendmidi(0x41);
  565. X    sendmidi(0x10);
  566. X    sendmidi(0x16);
  567. X    sendmidi(0x12);        /* DT1 - Data set 1 command */
  568. X    sendmidi(0x04);        /* address msb */
  569. X    cksum = 0x04;
  570. X    sendmidi(0x00);
  571. X    cksum += 0x00;
  572. X    sendmidi(0x00);        /* address lsb */
  573. X    cksum += 0x00;
  574. X    for(n = 0; n < D10TONSIZE; n++) {
  575. X        sendmidi(data[n + RESERVESIZE] & 0x7f);
  576. X        cksum += data[n + RESERVESIZE] & 0x7f;
  577. X    }
  578. X    sendmidi((-cksum) & 0x7f);    /* checksum */
  579. X    sendmidi(EOX);
  580. X}
  581. X
  582. X/*
  583. X * dtonnof
  584. X *
  585. X * Return a pointer to the voice name buried in library bank data.
  586. X */
  587. Xchar *
  588. Xdtonnof(data)
  589. Xchar *data;
  590. X{
  591. X    static char currbuff[11];
  592. X    char *p;
  593. X    int m;
  594. X
  595. X    p = currbuff;
  596. X    for ( m = 0 ; m < 10 ; m++ )
  597. X        *p++ = data[m + RESERVESIZE];
  598. X    *p = '\0';
  599. X    return(currbuff);
  600. X}
  601. X
  602. X/*
  603. X * dtonsnof
  604. X *
  605. X * Set the voice name buried in data to name.
  606. X */
  607. Xdtonsnof(data,name)
  608. Xchar *data;
  609. Xchar *name;
  610. X{
  611. X    char *p;
  612. X    int m;
  613. X
  614. X    for ( p = name, m = 0 ; *p != '\0' && m < 10 ; p++, m++ )
  615. X        data[m + RESERVESIZE] = *p;
  616. X    for ( ; m < 10 ; m++ )
  617. X        data[m + RESERVESIZE] = ' ';
  618. X}
  619. X
  620. X/* dtonsone - send a single voice to the D10 */
  621. Xdtonsone(iv, data)
  622. Xint iv;
  623. Xchar *data;
  624. X{
  625. X    int n;
  626. X    int cksum;
  627. X    long curadd;
  628. X    int addbyte;
  629. X
  630. X    curadd = TONBASEADDR;
  631. X
  632. X    for(n = 0; n < iv; n++) {
  633. X        curadd += 0x200;
  634. X        if((curadd & 0x8000) != 0) {
  635. X            curadd &= 0x7f7f7f;
  636. X            curadd += 0x10000;
  637. X        }
  638. X    }
  639. X
  640. X    sendmidi(0xf0);
  641. X    sendmidi(0x41);
  642. X    sendmidi(0x10);
  643. X    sendmidi(0x16);
  644. X    sendmidi(0x12);        /* DT1 - Data set 1 command */
  645. X    addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  646. X    sendmidi(addbyte);
  647. X    cksum = addbyte;
  648. X    addbyte = ((curadd >> 8) & 0x7f);
  649. X    sendmidi(addbyte);
  650. X    cksum += addbyte;
  651. X    addbyte = (curadd & 0x7f);        /* address lsb */
  652. X    sendmidi(addbyte);
  653. X    cksum += addbyte;
  654. X    for(n = 0; n < D10TONSIZE; n++) {
  655. X        sendmidi(data[n + RESERVESIZE] & 0x7f);
  656. X        cksum += data[n + RESERVESIZE] & 0x7f;
  657. X    }
  658. X    sendmidi((-cksum) & 0x7f);    /* checksum */
  659. X    sendmidi(EOX);
  660. X
  661. X    return(0);
  662. X}
  663. X
  664. X/* dtongbulk - Request and read a bulk dump from the D10 */
  665. Xdtongbulk(data)
  666. Xchar *data;
  667. X{
  668. X    static    char Buff[BUFSIZ];
  669. X    int c, n, v, b2, ret = 1;
  670. X    long begin, toolong, wait;
  671. X    long curadd;
  672. X    int addbyte;
  673. X    int cksum;
  674. X    
  675. X    sprintf(Buff,"\n");
  676. X    windstr(Buff);
  677. X    
  678. X    curadd = TONBASEADDR;
  679. X
  680. X    for(v = 0; v < Nvoices; v++) {
  681. X
  682. X        flushmidi();
  683. X
  684. X        if(v % 10 != 0) {
  685. X            sprintf(Buff, ".");
  686. X        } else {
  687. X            sprintf(Buff,"%d", (v / 10));
  688. X        }
  689. X        windstr(Buff);
  690. X
  691. X    /* request the voice */
  692. X        sendmidi(0xf0);
  693. X        sendmidi(0x41);
  694. X        sendmidi(0x10);
  695. X        sendmidi(0x16);
  696. X        sendmidi(0x11);        /* RQ1 - Data request 1 command */
  697. X
  698. X        addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  699. X        sendmidi(addbyte);
  700. X        cksum = addbyte;
  701. X        addbyte = ((curadd >> 8) & 0x7f);
  702. X        sendmidi(addbyte);
  703. X        cksum += addbyte;
  704. X        addbyte = (curadd & 0x7f);        /* address lsb */
  705. X        sendmidi(addbyte);
  706. X        cksum += addbyte;
  707. X
  708. X        sendmidi(0x00);        /* length msb */
  709. X        cksum += 0x00;
  710. X        sendmidi(0x01);        /* should be D10TONSIZE */
  711. X        cksum += 0x01;
  712. X        sendmidi(0x76);        /* length lsb */
  713. X        cksum += 0x76;
  714. X
  715. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  716. X        sendmidi(EOX);
  717. X    
  718. X    /* set up timeout */
  719. X        begin = milliclock();
  720. X        toolong = begin + (1000 * TIMEOUT);
  721. X    
  722. X    /* read header */
  723. X        for(n = 0; n < 8; ) {
  724. X            if ( STATMIDI ) {
  725. X                b2 = (getmidi() & 0xff);
  726. X                /* burn active sensing and timing clock */
  727. X                if((b2 != 0xfe) && (b2 != 0xf8))
  728. X                    n++;
  729. X            } else {
  730. X                if ( milliclock() > toolong ) {
  731. X                    Reason = "Timeout waiting for header";
  732. X                    goto getout;
  733. X                }
  734. X            }
  735. X        }
  736. X
  737. X    /* read data */
  738. X        for(n = 0; n < D10TONSIZE; ) {
  739. X            if ( STATMIDI ) {
  740. X                b2 = (getmidi() & 0xff);
  741. X                /* burn active sensing and timing clock */
  742. X                if((b2 != 0xfe) && (b2 != 0xf8)) {
  743. X                    VOICEBYTE(data,v,n + RESERVESIZE) = b2;
  744. X                    n++;
  745. X                }
  746. X            } else {
  747. X                if ( milliclock() > toolong ) {
  748. X                    Reason = "Timeout reading data";
  749. X                    goto timeout;
  750. X                }
  751. X            }
  752. X        }
  753. X
  754. X    timeout:
  755. X        if ( n != D10TONSIZE ) {
  756. X            Reason = "Timeout reading data!";
  757. X            goto getout;
  758. X        }
  759. X
  760. X    /* read checksum */
  761. X        for(n = 0; n < 1; ) {
  762. X            if ( STATMIDI ) {
  763. X                b2 = (getmidi() & 0xff);
  764. X                /* burn active sensing and timing clock */
  765. X                if((b2 != 0xfe) && (b2 != 0xf8))
  766. X                    n++;
  767. X            } else {
  768. X                if ( milliclock() > toolong ) {
  769. X                    Reason = "Timeout reading checksum";
  770. X                    goto getout;
  771. X                }
  772. X            }
  773. X        }
  774. X
  775. X    /* read EOX */
  776. X        for(n = 0; n < 1; ) {
  777. X            if ( STATMIDI ) {
  778. X                b2 = (getmidi() & 0xff);
  779. X                /* burn active sensing and timing clock */
  780. X                if((b2 != 0xfe) && (b2 != 0xf8))
  781. X                    if ( b2 != EOX ) {
  782. X                        sprintf(Buff,"EOX not received (%X)\n", b2);
  783. X                        Reason = Buff;
  784. X                        goto getout;
  785. X                    }
  786. X                    n++;
  787. X            } else {
  788. X                if ( milliclock() > toolong ) {
  789. X                    Reason = "Timeout reading EOX";
  790. X                    goto getout;
  791. X                }
  792. X            }
  793. X        }
  794. X        curadd += 0x200;        /* D10TONSIZE */
  795. X
  796. X        if((curadd & 0x8000) != 0) {
  797. X            curadd &= 0x7f7f7f;
  798. X            curadd += 0x10000;
  799. X        }
  800. X
  801. X    } /* go back for another voice */
  802. X
  803. X    Reason = "";
  804. X    ret = 0;    /* all's well */
  805. X
  806. Xgetout:
  807. X    return(ret);
  808. X}
  809. X
  810. X/* dtonsbulk - send a bulk dump to the D10 */
  811. Xdtonsbulk(data)
  812. Xchar *data;
  813. X{
  814. X    static char Buff[BUFSIZ];
  815. X    int v, n;
  816. X    int cksum;
  817. X    long curadd;
  818. X    int addbyte, databyte;
  819. X    int curoff;
  820. X
  821. X    curadd = TONBASEADDR;
  822. X    curoff = 0;    
  823. X    sprintf(Buff,"\nA: ");
  824. X    windstr(Buff);
  825. X
  826. X    for(v = 0; v <Nvoices ; v++) {
  827. X        if(v == 64) {
  828. X            sprintf(Buff,"\nB: ");
  829. X            windstr(Buff);
  830. X        }
  831. X        if((((v > 63) ? (v - 64) : v) % 10) != 0) {
  832. X            sprintf(Buff, ".");
  833. X        } else {
  834. X            sprintf(Buff,"%d", (((v > 63) ? (v - 64) : v) / 10));
  835. X        }
  836. X
  837. X        windstr(Buff);
  838. X        sendmidi(0xf0);
  839. X        sendmidi(0x41);
  840. X        sendmidi(0x10);
  841. X        sendmidi(0x16);
  842. X        sendmidi(0x12);        /* DT1 - Data set 1 command */
  843. X        addbyte = ((curadd >> 16) & 0x7f);    /* address msb */
  844. X        sendmidi(addbyte);
  845. X        cksum = addbyte;
  846. X        addbyte = ((curadd >> 8) & 0x7f);
  847. X        sendmidi(addbyte);
  848. X        cksum += addbyte;
  849. X        addbyte = (curadd & 0x7f);        /* address lsb */
  850. X        sendmidi(addbyte);
  851. X        cksum += addbyte;
  852. X
  853. X        for(n = 0; n < D10TONSIZE; n++) {
  854. X            databyte = data[curoff + n + RESERVESIZE] & 0x7f;
  855. X            sendmidi(databyte);
  856. X            cksum += databyte;
  857. X        }
  858. X        sendmidi((-cksum) & 0x7f);    /* checksum */
  859. X        sendmidi(EOX);
  860. X
  861. X        curadd += 0x200;        /* D10TONSIZE */
  862. X        if((curadd & 0x8000) != 0) {
  863. X            curadd &= 0x7f7f7f;
  864. X            curadd += 0x10000;
  865. X        }
  866. X        curoff += (D10TONSIZE + RESERVESIZE);
  867. X    }
  868. X    return(0);
  869. X}
  870. END_OF_FILE
  871. if test 7249 -ne `wc -c <'d10ton.c'`; then
  872.     echo shar: \"'d10ton.c'\" unpacked with wrong size!
  873. fi
  874. # end of 'd10ton.c'
  875. fi
  876. if test -f 'glib.1' -a "${1}" != "-c" ; then 
  877.   echo shar: Will not clobber existing file \"'glib.1'\"
  878. else
  879. echo shar: Extracting \"'glib.1'\" \(8007 characters\)
  880. sed "s/^X//" >'glib.1' <<'END_OF_FILE'
  881. X.TH GLIB 1 LOCAL
  882. X.SH NAME
  883. Xglib \- patch editor and librarian for synthesizers
  884. X.SH SYNOPSIS
  885. X.B glib
  886. X.SH DESCRIPTION
  887. X.I Glib
  888. X(one syllable) is a text-screen-oriented librarian
  889. Xand patch editor for electronic synthesizers.
  890. XIt is structured in an attempt to make it easy to add support for new
  891. Xsynthesizers.
  892. X.I Glib
  893. Xpresents three types of menu screens:
  894. Xsynthesizer selection, patch librarian, and patch editor.
  895. XHowever, depending on choices made when
  896. X.I glib
  897. Xwas compiled,
  898. Xthere may be no synthesizer selection menu, or it may
  899. Xbe used to select different sub-parts of a single synth, rather
  900. Xthan among different synths.
  901. XFrom the outermost selection menu
  902. Xyou descend to the librarian.
  903. XIf there is no synth selection menu, you see the librarian
  904. Xscreen immediately after invoking
  905. X.IR glib .
  906. X.PP
  907. XThe librarian part of the program manipulates 1 synth bank of voices
  908. X(which can be uploaded to or downloaded from the synth), and 3
  909. Xbanks of library voices (which can be read/written to disk).
  910. XWhen you exit the librarian and select a different synth,
  911. Xthe contents of the library banks and other settings (e.g.
  912. X.I midi
  913. Xchannel) for each are retained.
  914. X.PP
  915. XFrom the librarian screen you can descend to the patch editor
  916. Xscreen to change or create an individual patch for
  917. Xa given synthesizer.
  918. XDetails about using the librarian and the patch editor
  919. Xare given below.
  920. X.PP
  921. XThe
  922. X.I glib
  923. Xdistribution includes support files for various PCs -- IBM,
  924. XAtari ST, Macintosh, Amiga.
  925. XAnd you can run
  926. X.I glib
  927. Xon Unix (it uses curses), although obviously most
  928. XUnix machines don't have midi I/O.  Trying it out on Unix will give you a
  929. Xfeel for what the program does, so you can decide whether or not it's
  930. Xworth the trouble to port it to your
  931. Xmidi-capable PC.
  932. XOr your could edit patch files on a Unix system and download them
  933. Xto a PC.
  934. X.PP
  935. XThe current version of
  936. X.IR glib ,
  937. Xversion 1.6,
  938. Xsupports the synthesizers:
  939. XDX100, TX81, DEP5, DW8000, Roland D-10, Kawaii K1 \& K5, DX7,
  940. Xand Casio CZ1.
  941. X.SH Using glib - Moving around
  942. XBoth the librarian and editor parts of glib make use of arrow
  943. Xkeys,
  944. X.CT B
  945. X.CT N
  946. X.CT P
  947. X.CT F
  948. Xor
  949. X.B h j k l
  950. Xto move the cursor around.
  951. X(The arrow keys may not work on non-Unix versions, though.)
  952. X.CT L
  953. Xredraws the screen.  These
  954. Xkeys are
  955. X.I #defined
  956. Xin
  957. X.IR glib.h ,
  958. Xso you can change them if you want.
  959. XTo quit from any mode, use
  960. X.BR q .
  961. XIn the librarian screen,
  962. X.B ?
  963. Xgives
  964. Xa command summary.
  965. X.B Esc
  966. Xor grave accent key
  967. Xsends an all-notes-off (though the
  968. Xsupport for arrow keys may interfere with this use
  969. Xof
  970. X.B esc
  971. X).
  972. X.PP
  973. X.SH Using glib - The librarian
  974. XThe screen shows the synth bank on the left, and the current (1 of 3)
  975. Xlibrary bank on the right.  A
  976. X.B *
  977. Xidentifies the \*(lqcurrent\*(rq voice, and
  978. Xyou use the arrow keys to move it around.  As soon as you move to a different
  979. Xvoice, it is sent to the \*(lqedit buffer\*(rq of the synth, so it is very
  980. Xeasy to roam around and see what each voice sounds like.  Commands:
  981. X.TP
  982. X.B b \-
  983. XCycle through the (3) library banks, displayed on the
  984. Xright side of the screen.
  985. X.TP
  986. X.B c \-
  987. XSet the 
  988. X.I midi
  989. Xchannel for sending/receiving voices.
  990. X.TP
  991. X.B d \-
  992. XDownload from the (real) synthesizer, replacing the current
  993. Xcontents of the synth bank.
  994. X.TP
  995. X.B D \-
  996. XDownload from a file, replacing the current
  997. Xcontents of the synth bank.
  998. XSame as above, except input comes from file instead of the synth.
  999. X(Implemented only for Unix version.)
  1000. X.TP
  1001. X.B e \-
  1002. XEdit the current voice (see editor description below).
  1003. X.TP
  1004. X.B f \-
  1005. XList the files on the disk.
  1006. X.TP
  1007. X.B p \-
  1008. XPut the yank buffer, replacing the contents of the current voice.
  1009. X.TP
  1010. X.B q \-
  1011. XQuit, going back to \*(lqchoose a synth\*(rq.
  1012. X.TP
  1013. X.B r \-
  1014. XRead a bank of voices from a file, replacing entirely
  1015. Xthe current library bank.
  1016. X.TP
  1017. X.B R \-
  1018. XRead a bank of voices from a text file (created with the
  1019. X.B W
  1020. Xcommand).
  1021. X.TP
  1022. X.B s \-
  1023. XSwap the current voice with the yank buffer.  2 swaps is a no-op.
  1024. X.TP
  1025. X.B t \-
  1026. XTransfer all voices, either from the current library bank to
  1027. Xthe synth bank, or vice versa.
  1028. X.TP
  1029. X.B u \-
  1030. XUpload the current contents of the synth bank to the synth.
  1031. XYou are given a choice of sending the entire bank or just
  1032. Xthe current voice.
  1033. X.TP
  1034. X.B U \-
  1035. XUpload the current contents of the synth bank to a file.
  1036. XSame as above, except output goes to file instead of the synth.
  1037. X(Implemented only for Unix version.)
  1038. X.TP
  1039. X.B w \-
  1040. XWrite the current library bank to a file.
  1041. X.TP
  1042. X.B W \-
  1043. XWrite the current library bank to an editable text file.
  1044. XThis is slow, and is meant for use in some special
  1045. Xcircumstance \- for instance if you changed the binary
  1046. Xformat of files, you might want to convert your old patches.
  1047. X.TP
  1048. X.B y \-
  1049. XYank the current voice into the yank buffer, shown
  1050. Xin the middle of the screen.
  1051. X
  1052. X.SH Using glib - The editor
  1053. XIn the editor part, arrow keys move the cursor among the parameter
  1054. Xvalues.  The cursor will only land on parameter values.  Once on
  1055. Xa parameter value, the following keys will affect it:
  1056. X.TP
  1057. X.B K \-
  1058. Xincrease value by 1
  1059. X.TP
  1060. X.B J \-
  1061. Xdecrease value by 1
  1062. X.TP
  1063. X.B I \-
  1064. Xincrease value by 4
  1065. X.TP
  1066. X.B M \-
  1067. Xdecrease value by 4
  1068. X.TP
  1069. X.B < \-
  1070. Xdecrease value to its minimum
  1071. X.TP
  1072. X.B > \-
  1073. Xincrease value to its maximum
  1074. X.TP
  1075. X.B S \-
  1076. Xassign same value as last assigned
  1077. X.PP
  1078. XThese keys are defined in
  1079. X.IR glib.h ,
  1080. Xand should be changed to
  1081. Xsuit your own tastes.  I'm not thrilled with these choices, myself,
  1082. Xbut I had to use something, and at least the hand may stay in one place.
  1083. X.PP
  1084. XTo change the name of a voice, use \*(lqN\*(rq.
  1085. X.PP
  1086. XThe \*(lqauto-note\*(rq is played whenever you press the space bar.  This is
  1087. Xa convenient way of playing a note as soon as you make a change (ie.
  1088. Xyou can do everything from the computer keyboard).  You can change the
  1089. Xauto-note parameters (pitch, duration, volume, channel) the same way as all
  1090. Xthe other parameters.
  1091. X.SH Synthesizers
  1092. XHere is a list of the sample patch files for each synthesizer in the
  1093. X1.6 release of
  1094. X.IR glib ,
  1095. Xtogether with occasional notes on the current implementation.
  1096. X.TP
  1097. X.B DX100
  1098. XSample patches: fact1.dx1
  1099. X.TP
  1100. X.B TX81
  1101. XSample patches: fact1.t8p fact1.tx8
  1102. X.TP
  1103. X.B DEP5
  1104. XSample patches: fact1.dp5
  1105. X.TP
  1106. X.B DW8000
  1107. XSample patches: fact1.dw8
  1108. X.TP
  1109. X.B Roland D-10
  1110. XSample patches: d10fact.pat d10fact.rsu d10fact.tim d10fact.ton d10fact.tra d10fact.urp
  1111. X.TP
  1112. X.B Kawaii K1
  1113. XSample patches: k1fact.mlt k1fact.sgl
  1114. X.sp
  1115. X.RS
  1116. XVoices are not sent to the K1's edit buffer.
  1117. X.br
  1118. XFor Kawai K1 multi patches, names of single patches referred to are
  1119. Xdisplayed when they can be found in the synth voice bank of the
  1120. Xsingle patches module.  The names are updated whenever a new bank
  1121. Xof voices is transferred into this bank.
  1122. X.RE
  1123. X.TP
  1124. X.B Kawaii K5
  1125. XSample patches: card1.k5m card1.k5s
  1126. X.RS
  1127. XEditing of voices is not implemented.
  1128. X.RE
  1129. X.TP
  1130. X.B DX7
  1131. XSample patches: n001.dx7 rom1.d7s
  1132. X.sp
  1133. X.RS
  1134. XSome of the parameters on the DX7s editing screen
  1135. Xare \*(lqmultiplexed\*(rq.
  1136. XMove the cursor to the
  1137. X\*(lqModulation Wheel\*(rq legend, then
  1138. X\*(lqincrement\*(rq and \*(lqdecrement\*(rq this field:
  1139. Xthe fields below it will cycle
  1140. Xthrough the \*(lqModulation Wheel\*(rq,
  1141. X\*(lqAftertouch\*(rq, \*(lqBreath Control\*(rq,
  1142. X\*(lqFoot Control\*(rq, and \*(lqMIDI Control\*(rq parameters.
  1143. X.RE
  1144. X.TP
  1145. X.B Casio CZ1
  1146. XSample patches: bank1.cz1
  1147. X.sp
  1148. X.RS
  1149. XThe performance parameters given on the lower part of the editing
  1150. Xscreen, Glib, Portamento, etc., are just there
  1151. X.I pro
  1152. X.IR forma .
  1153. XIn the current version, setting them doesn't accomplish anything.
  1154. X.RE
  1155. X.SH AUTHORS
  1156. X.HP 
  1157. Xoriginal version for dx100, tx81z, dep5: Tim Thompson,
  1158. X...twitch!glimmer!tjt
  1159. X.HP 
  1160. XMacintosh and dw1000 support: Steve Falco.
  1161. X.HP 
  1162. Xd10 support: Michael Kesti, mrk@gvgspd.GVG.TEK.COM
  1163. X.HP 
  1164. XAmiga and k5 support: Alan Bland, mab@druwy.ATT.COM
  1165. Xor att!druwy!mab
  1166. X.HP  
  1167. XK1 support and menu mods: Greg Lee, lee@uhccux.uhcc.hawaii.edu
  1168. X.HP 
  1169. XDX7 support: Scott Snyder, ssnyder@citjulie.bitnet,
  1170. Xssnyder@juliet.caltech.edu (addresses valid until mid-June)
  1171. X.HP 
  1172. XCZ1 support:  Mark R. Rinfret, mrr@amanpt1.Newport.RI.US,
  1173. X...!rayssd!galaxia!amanpt1!mrr
  1174. X.HP
  1175. Xarp file requester, Amiga version:  Dave Weiler
  1176. X.PP
  1177. XSome of the code was originally written by Steve Frysinger
  1178. X(moss!spf), John Helton, and James Gosling.
  1179. END_OF_FILE
  1180. if test 8007 -ne `wc -c <'glib.1'`; then
  1181.     echo shar: \"'glib.1'\" unpacked with wrong size!
  1182. fi
  1183. # end of 'glib.1'
  1184. fi
  1185. if test -f 'k1vis.c' -a "${1}" != "-c" ; then 
  1186.   echo shar: Will not clobber existing file \"'k1vis.c'\"
  1187. else
  1188. echo shar: Extracting \"'k1vis.c'\" \(8018 characters\)
  1189. sed "s/^X//" >'k1vis.c' <<'END_OF_FILE'
  1190. X/* $Id: k1vis.c,v 1.6 89/05/06 17:13:28 lee Exp $
  1191. X * GLIB - a Generic LIBrarian and editor for synths
  1192. X *
  1193. X * Data Display Routines
  1194. X *
  1195. X * K1 version adapted from Kesti's D-10 version by Greg Lee
  1196. X * $Log:    k1vis.c,v $
  1197. X * Revision 1.6  89/05/06  17:13:28  lee
  1198. X * rel. to comp.sources.misc
  1199. X * 
  1200. X */
  1201. X
  1202. X#include <stdio.h>
  1203. X
  1204. Xextern int Redraw;    /* if non-0, edit screen is completely redrawn. */
  1205. X
  1206. Xchar *visnum();
  1207. X
  1208. Xchar *
  1209. Xvispnum(v)
  1210. X{
  1211. X    return(visnum(v+1));
  1212. X}
  1213. X
  1214. Xchar *
  1215. Xvispan(v)
  1216. X{
  1217. X    switch (v) {
  1218. X    case 0: return("R");
  1219. X    case 1: return("L+R");
  1220. X    case 2: return("L");
  1221. X    }
  1222. X    return("*");
  1223. X}
  1224. X
  1225. Xchar *
  1226. Xvispoly(v)
  1227. X{
  1228. X    switch (v) {
  1229. X    case 0: return("VR");
  1230. X    case 1: return("MUTE");
  1231. X    case 2: return("1");
  1232. X    case 3: return("2");
  1233. X    case 4: return("3");
  1234. X    case 5: return("4");
  1235. X    case 6: return("5");
  1236. X    case 7: return("6");
  1237. X    case 8: return("7");
  1238. X    case 9: return("8");
  1239. X    }
  1240. X    return("*");
  1241. X}
  1242. X
  1243. Xchar *
  1244. Xvisvelosw(v)
  1245. X{
  1246. X    switch (v) {
  1247. X    case 0: return("ALL");
  1248. X    case 1: return("SOFT");
  1249. X    case 2: return("LOUD");
  1250. X    }
  1251. X    return("*");
  1252. X}
  1253. X
  1254. Xchar *
  1255. Xvismode(v)
  1256. X{
  1257. X    switch (v) {
  1258. X    case 0: return("KYBD");
  1259. X    case 1: return("MIDI");
  1260. X    case 2: return("MIX");
  1261. X    }
  1262. X    return("*");
  1263. X}
  1264. X
  1265. Xchar *
  1266. Xvistwofour(v)
  1267. X{
  1268. X    switch (v) {
  1269. X    case 0: return("2");
  1270. X    case 1: return("4");
  1271. X    }
  1272. X    return("*");
  1273. X}
  1274. X
  1275. Xchar *
  1276. Xvismute(v)
  1277. X{
  1278. X    switch (v) {
  1279. X    case 0: return("ON");
  1280. X    case 1: return("MUTE");
  1281. X    }
  1282. X    return("*");
  1283. X}
  1284. X
  1285. Xchar *
  1286. Xvispolym(v)
  1287. X{
  1288. X    switch (v) {
  1289. X    case 0: return("PL1");
  1290. X    case 1: return("PL2");
  1291. X    case 2: return("SOLO");
  1292. X    }
  1293. X    return("*");
  1294. X}
  1295. X
  1296. Xchar *
  1297. Xvisvbwh(v)
  1298. X{
  1299. X    switch (v) {
  1300. X    case 0: return("DEP");
  1301. X    case 1: return("SPD");
  1302. X    }
  1303. X    return("*");
  1304. X}
  1305. X
  1306. Xchar *
  1307. Xviscrv(v)
  1308. X{
  1309. X    switch (v) {
  1310. X    case 0: return("1  /");
  1311. X    case 1: return("2 _--~u_");
  1312. X    case 2: return("3 _-~u__");
  1313. X    case 3: return("4 _/~u_");
  1314. X    case 4: return("5 _|~u_");
  1315. X    }
  1316. X    return("*");
  1317. X}
  1318. X
  1319. X
  1320. Xchar *viskeyshift(v)
  1321. X{
  1322. Xstatic char viskeyshiftbuf[4];
  1323. X
  1324. X    if((v >= 0) && (v <= 23)) {
  1325. X        (void)sprintf(viskeyshiftbuf,"-%d",abs(v - 24));
  1326. X        return(viskeyshiftbuf);
  1327. X    } else if(v == 24) {
  1328. X        (void)sprintf(viskeyshiftbuf,"0");
  1329. X        return(viskeyshiftbuf);
  1330. X    } else if((v >= 25) && (v <= 48)) {
  1331. X        (void)sprintf(viskeyshiftbuf,"+%d", (v - 24));
  1332. X        return(viskeyshiftbuf);
  1333. X    } else {
  1334. X        if (v < 0) return("-*"); else return("+*");
  1335. X    }
  1336. X}
  1337. X
  1338. Xchar *visfinetune(v)
  1339. X{
  1340. Xstatic char visfinetunebuf[4];
  1341. X
  1342. X    if((v >= 0) && (v <= 49)) {
  1343. X        (void)sprintf(visfinetunebuf,"-%d",abs(v - 50));
  1344. X        return(visfinetunebuf);
  1345. X    } else if(v == 50) {
  1346. X        (void)sprintf(visfinetunebuf,"0");
  1347. X        return(visfinetunebuf);
  1348. X    } else if((v >= 51) && (v <= 100)) {
  1349. X        (void)sprintf(visfinetunebuf,"+%d",(v - 50));
  1350. X        return(visfinetunebuf);
  1351. X    } else {
  1352. X        return("*");
  1353. X    }
  1354. X}
  1355. X
  1356. Xstatic    char *cpitch_table[] = {
  1357. X    "C",
  1358. X    "C#",
  1359. X    "D",
  1360. X    "D#",
  1361. X    "E",
  1362. X    "F",
  1363. X    "F#",
  1364. X    "G",
  1365. X    "G#",
  1366. X    "A",
  1367. X    "A#",
  1368. X    "B"
  1369. X};
  1370. X
  1371. Xchar *
  1372. Xviscpitch(v)
  1373. X{
  1374. Xstatic    char    viscpitchbuf[4];
  1375. X
  1376. X    if((v >= 0) && (v <= 127)) {
  1377. X        strcpy(viscpitchbuf, cpitch_table[v % 12]);
  1378. X        if(strlen(viscpitchbuf) == 1) {
  1379. X            (void)sprintf(viscpitchbuf+1, "%d", v/12 - 2);
  1380. X        } else {
  1381. X            (void)sprintf(viscpitchbuf+2, "%d", v/12 - 2);
  1382. X        }
  1383. X        return(viscpitchbuf);
  1384. X    } else {
  1385. X    return("*");
  1386. X    }
  1387. X}
  1388. X
  1389. Xchar *
  1390. Xvislpitch(v)
  1391. X{
  1392. Xstatic    char    vislpitchbuf[4];
  1393. X
  1394. X    if((v >= 0) && (v <= 127)) {
  1395. X        strcpy(vislpitchbuf, cpitch_table[v % 12]);
  1396. X        if(strlen(vislpitchbuf) == 1) {
  1397. X            (void)sprintf(vislpitchbuf+1, "%d", v/12 - 4);
  1398. X        } else {
  1399. X            (void)sprintf(vislpitchbuf+2, "%d", v/12 - 4);
  1400. X        }
  1401. X        return(vislpitchbuf);
  1402. X    } else {
  1403. X    return("*");
  1404. X    }
  1405. X}
  1406. X
  1407. Xchar *visonoff();
  1408. X
  1409. Xint ky_tk1=0, ky_tk2=0, ky_tk3=0, ky_tk4=0;
  1410. X
  1411. Xchar *visonoffk1(v) { ky_tk1 = v; Redraw = 1; return(visonoff(v)); }
  1412. Xchar *visonoffk2(v) { ky_tk2 = v; Redraw = 1; return(visonoff(v)); }
  1413. Xchar *visonoffk3(v) { ky_tk3 = v; Redraw = 1; return(visonoff(v)); }
  1414. Xchar *visonoffk4(v) { ky_tk4 = v; Redraw = 1; return(visonoff(v)); }
  1415. X
  1416. Xchar *
  1417. Xviscsfnk1(v) {if (ky_tk1) return(viskeyshift(v-60)); else return(vislpitch(v));}
  1418. Xchar *
  1419. Xviscsfnk2(v) {if (ky_tk2) return(viskeyshift(v-60)); else return(vislpitch(v));}
  1420. Xchar *
  1421. Xviscsfnk3(v) {if (ky_tk3) return(viskeyshift(v-60)); else return(vislpitch(v));}
  1422. Xchar *
  1423. Xviscsfnk4(v) {if (ky_tk4) return(viskeyshift(v-60)); else return(vislpitch(v));}
  1424. X
  1425. Xchar *
  1426. Xvisam1(v)
  1427. X{
  1428. X    switch(v) {
  1429. X    case 0: return("OFF");
  1430. X    case 1: return("2>1");
  1431. X    case 2: return("1>2");
  1432. X    }
  1433. X    return("*");
  1434. X}
  1435. X
  1436. Xchar *
  1437. Xvisam3(v)
  1438. X{
  1439. X    switch(v) {
  1440. X    case 0: return("OFF");
  1441. X    case 1: return("4>3");
  1442. X    case 2: return("3>4");
  1443. X    }
  1444. X    return("*");
  1445. X}
  1446. X
  1447. X
  1448. Xchar *visifosh(v)
  1449. X{
  1450. X    switch (v) {
  1451. X    case 0: return("TRI");
  1452. X    case 1: return("SAW");
  1453. X    case 2: return("SQR");
  1454. X    case 3: return("RND");
  1455. X    }
  1456. X    return("*");
  1457. X}
  1458. X
  1459. Xstatic    char *wave_table[] = {
  1460. X    "sin 1st",
  1461. X    "sin 2nd",
  1462. X    "sin 3rd",
  1463. X    "sin 4th",
  1464. X    "sin 5th",
  1465. X    "sin 6th",
  1466. X    "sin 7th",
  1467. X    "sin 8th",
  1468. X    "sin 9th",
  1469. X    "sin 10th",
  1470. X    "sin 11th",
  1471. X    "sin 12th",
  1472. X    "sin 16th",
  1473. X    "saw 1",
  1474. X    "saw 2",
  1475. X    "saw 3",
  1476. X    "saw 4",
  1477. X    "saw 5",
  1478. X    "saw 6",
  1479. X    "saw 7",
  1480. X    "saw 8",
  1481. X    "saw 9",
  1482. X    "saw 10",
  1483. X    "saw 11",
  1484. X    "saw 12",
  1485. X    "saw 13",
  1486. X    "saw 14",
  1487. X    "saw 15",
  1488. X    "saw 16",
  1489. X    "saw 17",
  1490. X    "saw 18",
  1491. X    "saw 19",
  1492. X    "square 1",
  1493. X    "square 2",
  1494. X    "square 3",
  1495. X    "square 4",
  1496. X    "square 5",
  1497. X    "inverse-saw",
  1498. X    "triangle",
  1499. X    "random",
  1500. X    "french horn",
  1501. X    "string",
  1502. X    "string",
  1503. X    "string pad",
  1504. X    "piano 1",
  1505. X    "el. grand",
  1506. X    "e. piano 1",
  1507. X    "e. piano 2",
  1508. X    "e. piano 3",
  1509. X    "clavi",
  1510. X    "vibe",
  1511. X    "a. guitar",
  1512. X    "f. guitar",
  1513. X    "f. guitar",
  1514. X    "ac bass",
  1515. X    "ac bass",
  1516. X    "digi bass 1",
  1517. X    "pick bass",
  1518. X    "digi bass 2",
  1519. X    "round bass",
  1520. X    "fretless",
  1521. X    "fretless",
  1522. X    "flute",
  1523. X    "panflute",
  1524. X    "harmonica",
  1525. X    "glocken",
  1526. X    "tine",
  1527. X    "harp",
  1528. X    "marimba",
  1529. X    "e. tom",
  1530. X    "log drum",
  1531. X    "jass organ 1",
  1532. X    "mello pad",
  1533. X    "synth solo",
  1534. X    "synth 2",
  1535. X    "french horn",
  1536. X    "french horn",
  1537. X    "brass",
  1538. X    "brass",
  1539. X    "brass",
  1540. X    "brass",
  1541. X    "trumpet",
  1542. X    "trumpet",
  1543. X    "violin",
  1544. X    "string",
  1545. X    "piano 1",
  1546. X    "piano 2",
  1547. X    "piano 3",
  1548. X    "piano 2",
  1549. X    "piano 3",
  1550. X    "piano 4",
  1551. X    "piano 4",
  1552. X    "el. grand",
  1553. X    "e. piano 1",
  1554. X    "e. piano 2",
  1555. X    "e. piano 3",
  1556. X    "clavi",
  1557. X    "harpsichord",
  1558. X    "vibe",
  1559. X    "a. guitar",
  1560. X    "f. guitar",
  1561. X    "strat",
  1562. X    "strat",
  1563. X    "ac bass",
  1564. X    "pull bass",
  1565. X    "pull bass",
  1566. X    "round bass",
  1567. X    "slap bass",
  1568. X    "slap bass",
  1569. X    "slap bass",
  1570. X    "fretless",
  1571. X    "fretless",
  1572. X    "synth bass",
  1573. X    "synth bass",
  1574. X    "harmonica",
  1575. X    "clarinet",
  1576. X    "clarinet",
  1577. X    "oboe",
  1578. X    "oboe",
  1579. X    "shakuhachi",
  1580. X    "oriental bell",
  1581. X    "oriental bell",
  1582. X    "bell",
  1583. X    "koto",
  1584. X    "sitar",
  1585. X    "e. tom",
  1586. X    "log drum",
  1587. X    "log drum",
  1588. X    "steel drum",
  1589. X    "steel drum",
  1590. X    "voice 1",
  1591. X    "voice 2",
  1592. X    "accordion",
  1593. X    "accordion",
  1594. X    "jass organ 2",
  1595. X    "rock organ 1",
  1596. X    "draw bar 1",
  1597. X    "draw bar 2",
  1598. X    "pipe organ 1",
  1599. X    "pipe organ 2",
  1600. X    "rock organ 2",
  1601. X    "synth solo",
  1602. X    "synth solo",
  1603. X    "synth 2",
  1604. X    "synth 2",
  1605. X    "synth 3",
  1606. X    "brass",
  1607. X    "brass",
  1608. X    "orchestra",
  1609. X    "piano 1",
  1610. X    "piano 4",
  1611. X    "e. piano 1",
  1612. X    "e. piano 1",
  1613. X    "e. piano 2",
  1614. X    "e. piano 3",
  1615. X    "clavi",
  1616. X    "harpsichord",
  1617. X    "harpsichord",
  1618. X    "vibe",
  1619. X    "digi bass 1",
  1620. X    "digi bass 2",
  1621. X    "digi bass 2",
  1622. X    "pick bass",
  1623. X    "glocken",
  1624. X    "glocken",
  1625. X    "tine",
  1626. X    "tine",
  1627. X    "tine",
  1628. X    "tube bell",
  1629. X    "tube bell",
  1630. X    "tube bell",
  1631. X    "xylophone",
  1632. X    "xylophone",
  1633. X    "harp",
  1634. X    "koto",
  1635. X    "sitar",
  1636. X    "sitar",
  1637. X    "kalimba",
  1638. X    "kalimba",
  1639. X    "kalimba",
  1640. X    "log drum",
  1641. X    "steel drum",
  1642. X    "pipe organ 3",
  1643. X    "pipe organ 3",
  1644. X    "synth 1",
  1645. X    "synth 2",
  1646. X    "synth 3",
  1647. X    "synth 3",
  1648. X    "synth 4",
  1649. X    "synth 4",
  1650. X    "clavi",
  1651. X    "digi bass 1",
  1652. X    "digi bass 1",
  1653. X    "pick bass",
  1654. X    "pick bass",
  1655. X    "round bass",
  1656. X    "round bass",
  1657. X    "harmonica",
  1658. X    "harmonica",
  1659. X    "harp",
  1660. X    "koto",
  1661. X    "sitar",
  1662. X    "marimba",
  1663. X    "synth 1",
  1664. X    "base drum",
  1665. X    "ac snare",
  1666. X    "tight snare",
  1667. X    "e. snare",
  1668. X    "rim",
  1669. X    "ac tom",
  1670. X    "h. hat",
  1671. X    "crach",
  1672. X    "ride",
  1673. X    "strat guitar",
  1674. X    "fuzz mute",
  1675. X    "a. guitar",
  1676. X    "f. guitar",
  1677. X    "guitar harmo",
  1678. X    "pull bass",
  1679. X    "bass harmo",
  1680. X    "bowed string",
  1681. X    "string attack",
  1682. X    "string sus",
  1683. X    "pizzicato",
  1684. X    "piano",
  1685. X    "el. grand",
  1686. X    "piano noise",
  1687. X    "trumpet",
  1688. X    "shakuhachi attack",
  1689. X    "shakuhachi sus",
  1690. X    "pan flute attack",
  1691. X    "pan flute sus",
  1692. X    "voice",
  1693. X    "white noise",
  1694. X    "string loop",
  1695. X    "shakuhachi loop",
  1696. X    "pan flute loop",
  1697. X    "voice loop",
  1698. X    "white noise loop",
  1699. X    "ac snare loop",
  1700. X    "f. guitar loop",
  1701. X    "pull bass loop",
  1702. X    "omn. loop 1",
  1703. X    "omn. loop 2",
  1704. X    "omn. loop 3",
  1705. X    "omn. loop 4",
  1706. X    "omn. loop 5",
  1707. X    "omn. loop 6",
  1708. X    "omn. loop 7",
  1709. X    "omn. loop 8",
  1710. X    "ac snare rev",
  1711. X    "ac tom rev",
  1712. X    "f. guitar rev",
  1713. X    "h. hat alt",
  1714. X    "crash alt",
  1715. X    "piano noise alt"
  1716. X};
  1717. X
  1718. Xchar *
  1719. Xviswave(v)
  1720. X{    static char wavebuf[30];
  1721. X
  1722. X    if (v >= 0 && v <= 255) {
  1723. X        (void)sprintf(wavebuf, "%3d %s", v+1, wave_table[v]);
  1724. X        return(wavebuf);
  1725. X    }
  1726. X    return("*");
  1727. X}
  1728. X
  1729. X/* end */
  1730. END_OF_FILE
  1731. if test 8018 -ne `wc -c <'k1vis.c'`; then
  1732.     echo shar: \"'k1vis.c'\" unpacked with wrong size!
  1733. fi
  1734. # end of 'k1vis.c'
  1735. fi
  1736. if test -f 'mac-mach.c' -a "${1}" != "-c" ; then 
  1737.   echo shar: Will not clobber existing file \"'mac-mach.c'\"
  1738. else
  1739. echo shar: Extracting \"'mac-mach.c'\" \(6397 characters\)
  1740. sed "s/^X//" >'mac-mach.c' <<'END_OF_FILE'
  1741. X/* $Id: mac-mach.c,v 1.6 89/05/06 17:13:32 lee Exp $
  1742. X * GLIB - a Generic LIBrarian and editor for synths
  1743. X *
  1744. X * Machine dependent stuff.
  1745. X *
  1746. X * macintosh version  -  Steven A. Falco  8/24/87
  1747. X * $Log:    mac-mach.c,v $
  1748. X * Revision 1.6  89/05/06  17:13:32  lee
  1749. X * rel. to comp.sources.misc
  1750. X * 
  1751. X */
  1752. X
  1753. X#include "glib.h"
  1754. X#include <ctype.h>
  1755. X
  1756. Xint Rows, Cols;
  1757. X
  1758. Xhello()
  1759. X{
  1760. X
  1761. X#ifdef MPW
  1762. X    /* Substitute our vt driver for the standard console driver.
  1763. X     * Use slot 1 since that is where the standard driver lives.
  1764. X     * This will magically hook in printf, etc.  We could do dups
  1765. X     * and closes which might be more portable, but we'd still need
  1766. X     * the _addDevHandler() call.  This is all subject to change when
  1767. X     * MPW 2.0 rolls around.
  1768. X     *
  1769. X     * NOTE: vt_read is unused in keynote.  Vt_getch and vt_peekch are
  1770. X     * used instead to avoid all system buffering.
  1771. X     */
  1772. X    _addDevHandler(1, 'CONS', vt_faccess, vt_close, vt_read, vt_write, vt_ioctl);
  1773. X    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
  1774. X    vt_raw(); /* want ^D to work as vanilla character */
  1775. X#endif
  1776. X
  1777. X    midi_init();
  1778. X}
  1779. X
  1780. Xbye()
  1781. X{
  1782. X    { int waste_time;
  1783. X    while(midi_txst == MIDI_NE) /* wait for all notes to drain */
  1784. X        ;
  1785. X    for(waste_time = 0; waste_time < (1 << 14); waste_time++)
  1786. X        ; /* hardware fifo has to drain too */
  1787. X    midi_reset(); /* now we can shut it down */
  1788. X    }
  1789. X    windgoto(23,0);
  1790. X    windrefresh();
  1791. X    exit(0);
  1792. X}
  1793. X
  1794. Xflushconsole()
  1795. X{
  1796. X    while ( statconsole() )
  1797. X        getconsole();
  1798. X}
  1799. X
  1800. Xstatconsole()
  1801. X{
  1802. X    fflush(stdout);    /* make sure we see prompts */
  1803. X    return(vt_peekch());
  1804. X}
  1805. X
  1806. Xgetconsole()
  1807. X{
  1808. X    fflush(stdout); /* flush any prompts */
  1809. X    return(vt_getch());
  1810. X}
  1811. X
  1812. Xgetmidi()
  1813. X{
  1814. X    int i;
  1815. X    
  1816. X    while((i = midi_rx()) == -1)
  1817. X        ; /* wait for something good */
  1818. X    
  1819. X    return(i);
  1820. X}
  1821. X
  1822. Xsendmidi(c)
  1823. X{
  1824. X    while(STATTXBF) /* it is easy to overrun on bulk dumps - slow down to uart rate */
  1825. X        ; /* wait till last character goes to uart */
  1826. X        
  1827. X    midi_tx(c);
  1828. X}
  1829. X
  1830. Xflushmidi()
  1831. X{
  1832. X    while ( STATMIDI )
  1833. X        getmidi(); /* flush any and all characters */
  1834. X}
  1835. X
  1836. X/* return relative time in 1mS steps */
  1837. Xlong milliclock()
  1838. X{
  1839. X    /* relative, free-running millisecond counter (5mS granularity) */
  1840. X    return(midi_time);
  1841. X}
  1842. X
  1843. Xmillisleep(i)
  1844. Xint i;
  1845. X{
  1846. X    long j = milliclock();
  1847. X    
  1848. X    while(i + j > milliclock())
  1849. X        ;
  1850. X    
  1851. X    return;
  1852. X}
  1853. X
  1854. Xint Paw;
  1855. XFileParam pblock;
  1856. XVolumeParam dblock;
  1857. XFInfo *fp;
  1858. XStr255 dummystr;
  1859. X
  1860. X/* Establish a "working directory reference number" for the user-specified
  1861. X * directory (path) in character array "pre".  This only affects
  1862. X * those calls that explicitly use the reference number - namely, the 
  1863. X * PBGetFInfo() call below.  In particular, none of this has any effect
  1864. X * whatsoever on fopen() calls.  For those, a full path name must be used.
  1865. X */
  1866. Xopenphr(pre)
  1867. Xchar *pre; /* the path prefix */
  1868. X{
  1869. X    strcpy(&dummystr, pre);    /* make a copy 'cause we change it */
  1870. X    c2pstr(&dummystr);    /* we need a pascal string */
  1871. X    dblock.ioCompletion = 0;
  1872. X    dblock.ioNamePtr = &dummystr;    /* this is the directory path in pascal */
  1873. X    dblock.ioVRefNum = 0;    /* start at the root */
  1874. X    
  1875. X    if(*((short *) FSFCBLen) > 0) {    /* we are running HFS */
  1876. X        ((WDPBRec *) &dblock)->ioWDProcID = SIGNATURE;    /* our ID */
  1877. X        ((WDPBRec *) &dblock)->ioWDDirID = 0;
  1878. X        if(PBOpenWD(&dblock, false) != noErr) {
  1879. X            printf("No such directory! (%s)\n", pre);
  1880. X            dblock.ioVRefNum = 0; /* force back to current directory */
  1881. X            pre[0] = 0; /* nuke the path or we'll get in trouble! */
  1882. X            /* we could also use a return code to abort the whole
  1883. X             * thing if desired.
  1884. X             */
  1885. X        }
  1886. X    } else {
  1887. X        dblock.ioVolIndex = -1;
  1888. X        if(PBGetVInfo(&dblock, false) != noErr) {
  1889. X            printf("No such directory! (%s)\n", pre);
  1890. X            dblock.ioVRefNum = 0; /* force back to current directory */
  1891. X            pre[0] = 0; /* nuke the path or we'll get in trouble! */
  1892. X            /* we could also use a return code to abort the whole
  1893. X             * thing if desired.
  1894. X             */    
  1895. X        }
  1896. X    }
  1897. X    
  1898. X    Paw = 0;
  1899. X    fp = &(pblock.ioFlFndrInfo);
  1900. X    pblock.ioCompletion = 0;
  1901. X    pblock.ioVRefNum = dblock.ioVRefNum;    /* use new directory number */
  1902. X    pblock.ioFVersNum = 0;
  1903. X}
  1904. X
  1905. X/* Return JUST THE FILENAME COMPONENT of the next phrase file we find. */
  1906. Xchar *
  1907. Xnextphr()
  1908. X{
  1909. X    static char fname[36];
  1910. X    char *p, *strrchr();
  1911. X
  1912. X    retry:
  1913. X    Paw++;
  1914. X
  1915. X    /* this is a little complicated... */
  1916. X    /* we go through the whole directory in sequence */
  1917. X    pblock.ioNamePtr = &dummystr;
  1918. X    pblock.ioFDirIndex = Paw;
  1919. X    if(PBGetFInfo(&pblock, false) != noErr) {
  1920. X        /* no such file - we hit the end of the directory */
  1921. X        return(NULL);
  1922. X    }
  1923. X
  1924. X    /* OK - we have some file info */
  1925. X    p2cstr(pblock.ioNamePtr); /* convert from Pascal to C format */
  1926. X    /* NOTE - '' rather than "" is correct! */
  1927. X    if(fp->fdType != 'TEXT') {
  1928. X        goto retry; /* not one of ours */
  1929. X    }
  1930. X    /* make it available as a static string */
  1931. X    strncpy(fname, pblock.ioNamePtr, 35); /* the file name */
  1932. X    fname[35] = 0; /* insist on a null - really can't happen :-) */
  1933. X    return(fname);
  1934. X}
  1935. Xclosephr()
  1936. X{
  1937. X}
  1938. X
  1939. X/* getmouse - get currect row and column of mouse */
  1940. Xgetmouse(amr,amc)
  1941. Xint *amr;
  1942. Xint *amc;
  1943. X{
  1944. X    *amr = -1;
  1945. X    *amc = -1;
  1946. X}
  1947. X
  1948. X/* statmouse - return mouse button state (0=nothing pressed,1=left,2=right) */
  1949. Xstatmouse()
  1950. X{
  1951. X    return(-1);
  1952. X}
  1953. X
  1954. Xmouseon()
  1955. X{
  1956. X}
  1957. X
  1958. Xmouseoff()
  1959. X{
  1960. X}
  1961. X
  1962. X/* Return when either a console key or mouse button is pressed. */
  1963. Xmouseorkey()
  1964. X{
  1965. X    return(getconsole());
  1966. X}
  1967. X
  1968. Xchar *
  1969. Xalloc(n)
  1970. X    unsigned n;
  1971. X{
  1972. X    char *p;
  1973. X
  1974. X    if ( (p = malloc(n)) == NULL ) {
  1975. X        printf("*** Whoops *** alloc has failed?!?  No more memory!\n");
  1976. X        fflush(stdout);
  1977. X        bye();
  1978. X    }
  1979. X    return(p);
  1980. X}
  1981. X
  1982. Xwindinit()
  1983. X{
  1984. X    Rows = 24;
  1985. X    Cols = 80;
  1986. X    
  1987. X    return;
  1988. X}
  1989. X
  1990. Xwindgoto(r,c)
  1991. Xint r,c;
  1992. X{
  1993. X    printf("\033[%d;%dH",r+1,c+1);
  1994. X}
  1995. X
  1996. Xwindeeol()
  1997. X{
  1998. X    printf("\033[K");
  1999. X}
  2000. X
  2001. Xwinderaserow(r)
  2002. X{
  2003. X    windgoto(r,0);
  2004. X    windeeol();
  2005. X}
  2006. X
  2007. Xwindexit(r)
  2008. Xint r;
  2009. X{
  2010. X    bye();
  2011. X}
  2012. X
  2013. Xwindclear()
  2014. X{
  2015. X    printf("\033[H");
  2016. X    printf("\033[J");
  2017. X}
  2018. X
  2019. X/* windgets - get a line of input from the console, handling backspaces */
  2020. Xwindgets(s)
  2021. Xchar *s;
  2022. X{
  2023. X    char *origs = s;
  2024. X    int c;
  2025. X
  2026. X    while ( (c=getconsole()) != '\n' && c!='\r' && c!= EOF ) {
  2027. X        if ( c == '\b' ) {
  2028. X            if ( s > origs ) {
  2029. X                windstr("\b \b");
  2030. X                s--;
  2031. X            }
  2032. X        }
  2033. X        else {
  2034. X            windputc(c);
  2035. X            *s++ = c;
  2036. X        }
  2037. X        windrefresh();
  2038. X    }
  2039. X    *s = '\0';
  2040. X}
  2041. X
  2042. Xwindstr(s)
  2043. Xchar *s;
  2044. X{
  2045. X    int c;
  2046. X
  2047. X    while ( (c=(*s++)) != '\0' )
  2048. X        windputc(c);
  2049. X}
  2050. X
  2051. Xwindputc(c)
  2052. Xint c;
  2053. X{
  2054. X    putchar(c);
  2055. X}
  2056. X
  2057. Xwindrefresh()
  2058. X{
  2059. X}
  2060. X
  2061. Xbeep()
  2062. X{
  2063. X    putchar('\007');
  2064. X}
  2065. X
  2066. Xwindhigh()
  2067. X{
  2068. X}
  2069. X
  2070. Xwindnorm()
  2071. X{
  2072. X}
  2073. X
  2074. Xchar *
  2075. Xopenls()
  2076. X{
  2077. X    /* this should be a whole lot fancier to take care of the path
  2078. X     * problems on the mac.  But glib currently has no path
  2079. X     * variables.  The current directory (just ":") will do for now... SAF
  2080. X     */
  2081. X    openphr(":");
  2082. X    return("");
  2083. X}
  2084. X
  2085. Xchar *
  2086. Xnextls()
  2087. X{
  2088. X    return(nextphr());
  2089. X}
  2090. X
  2091. Xclosels()
  2092. X{
  2093. X}
  2094. END_OF_FILE
  2095. if test 6397 -ne `wc -c <'mac-mach.c'`; then
  2096.     echo shar: \"'mac-mach.c'\" unpacked with wrong size!
  2097. fi
  2098. # end of 'mac-mach.c'
  2099. fi
  2100. if test -f 'tx81z.mnu' -a "${1}" != "-c" ; then 
  2101.   echo shar: Will not clobber existing file \"'tx81z.mnu'\"
  2102. else
  2103. echo shar: Extracting \"'tx81z.mnu'\" \(6230 characters\)
  2104. sed "s/^X//" >'tx81z.mnu' <<'END_OF_FILE'
  2105. X/* $Id: tx81z.mnu,v 1.6 89/05/06 17:13:45 lee Exp $
  2106. X * GLIB - a Generic LIBrarian and editor for synths
  2107. X *
  2108. X * TX81Z routines for Patch parameters
  2109. X * Tim Thompson
  2110. X * modifications: Greg Lee
  2111. X * $Log:    tx81z.mnu,v $
  2112. X * Revision 1.6  89/05/06  17:13:45  lee
  2113. X * rel. to comp.sources.misc
  2114. X * 
  2115. X */
  2116. X
  2117. X#define OVERLAY1
  2118. X
  2119. X#include "glib.h"
  2120. X#include <ctype.h>
  2121. X
  2122. Xchar *visnum(), *visonoff(), *vism3num(), *viswave(), *vismono();
  2123. Xchar *visdx1a(), *vistxwave(), *vistxsft();
  2124. Xchar *vistf1(), *vistf2(), *vistf3(), *vistf4();
  2125. Xchar *visfx(), *visfx1(), *visfx2(), *visfx3(), *visfx4();
  2126. Xextern int Dopmap[];
  2127. X
  2128. X#define RESERVESIZE 0
  2129. X
  2130. X/* This array contains arbitrary screen labels */
  2131. Xstruct labelinfo Ltx81z[] = {
  2132. X#MENU
  2133. X
  2134. X                                                 Algorithm   %
  2135. X                                                 =============
  2136. X
  2137. X
  2138. X O       Dcy Lev Dcy               De  Out     Amp Eg  Key Key EG
  2139. X P   Atk  1   1   2  Rls Wav  Freq tun Lvl Vel Mod Bia Rat Scl Sft Fix/Ratio
  2140. X -   --- --- --- --- --- --- ----- --- --- --- --- --- --- --- --- ---------
  2141. X 1    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
  2142. X 2    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
  2143. X 3    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
  2144. X 4    %   %   %   %   %   %   %     %   %   %  %    %   %   %  %     %
  2145. X
  2146. X           Reverb Rate  %        Feedback    %         Mono/Poly          %
  2147. X           FC Pitch     %        Transpose   %         Amp Mod Depth      %
  2148. X           FC Amp       %        LFO Speed   %         Amp Mod Sense      %
  2149. X                                 LFO Delay   %         Pitch Mod Depth    %
  2150. X-------------------------+       LFO Wave    %         Pitch Mod Sense    %
  2151. XN = set name  q = quit   |       LFO Sync    %         Mod Pitch Range    %
  2152. XK = incr      J = decr   |       Pitch Bend  %         Mod Amp Range      %
  2153. Xspace = play auto-note   |       Port. Time  %         Breath Pitch       %
  2154. X                         |       Port. Mode  %         Breath Amp         %
  2155. XAuto-Note: Pitch %       |       Port. Foot  %         Breath Pitch Bias  %
  2156. XVol %   Dur %   Chan %   |       Sus. Foot   %         Breath EG Bias     %
  2157. X#END
  2158. X-1,-1,NULL
  2159. X};
  2160. X
  2161. Xstruct paraminfo  Ptx81z[] =  {
  2162. X/*
  2163. XNAME        TYPE    POS    MAX    OFFSET    MASK    SHIFT    ADHOC
  2164. X */
  2165. X#O algorithm    dx1a    %%    7    0
  2166. X#O op1attack    num    %%    31    0
  2167. X#O op1decay1    num    %%    31    0
  2168. X#O op1level1    num    %%    15    0
  2169. X#O op1decay2    num    %%    31    0
  2170. X#O op1release    num    %%    31    0
  2171. X#O op1wave    txwave    %%    7    0
  2172. X#O op1freq    tf1    %%    878    0
  2173. X#O op1detune    m3num    %%    6    0
  2174. X#O op1outlevel    num    %%    99    0
  2175. X#O op1velocity    num    %%    7    0
  2176. X#O op1ampmod    onoff    %%    1    0
  2177. X#O op1egbias    num    %%    7    0
  2178. X#O op1keyrate    num    %%    3    0
  2179. X#O op1keyscale    num    %%    99    0
  2180. X#O op1egsft    txsft    %%    3    0
  2181. X#O op1fix    fx1    %%    1    0
  2182. X#O op2attack    num    %%    31    0
  2183. X#O op2decay1    num    %%    31    0
  2184. X#O op2level1    num    %%    15    0
  2185. X#O op2decay2    num    %%    31    0
  2186. X#O op2release    num    %%    31    0
  2187. X#O op2wave    txwave    %%    7    0
  2188. X#O op2freq    tf2    %%    878    0
  2189. X#O op2detune    m3num    %%    6    0
  2190. X#O op2outlevel    num    %%    99    0
  2191. X#O op2velocity    num    %%    7    0
  2192. X#O op2ampmod    onoff    %%    1    0
  2193. X#O op2egbias    num    %%    7    0
  2194. X#O op2keyrate    num    %%    3    0
  2195. X#O op2keyscale    num    %%    99    0
  2196. X#O op2egsft    txsft    %%    3    0
  2197. X#O op2fix    fx2    %%    1    0
  2198. X#O op3attack    num    %%    31    0
  2199. X#O op3decay1    num    %%    31    0
  2200. X#O op3level1    num    %%    15    0
  2201. X#O op3decay2    num    %%    31    0
  2202. X#O op3release    num    %%    31    0
  2203. X#O op3wave    txwave    %%    7    0
  2204. X#O op3freq    tf3    %%    878    0
  2205. X#O op3detune    m3num    %%    6    0
  2206. X#O op3outlevel    num    %%    99    0
  2207. X#O op3velocity    num    %%    7    0
  2208. X#O op3ampmod    onoff    %%    1    0
  2209. X#O op3egbias    num    %%    7    0
  2210. X#O op3keyrate    num    %%    3    0
  2211. X#O op3keyscale    num    %%    99    0
  2212. X#O op3egsft    txsft    %%    3    0
  2213. X#O op3fix    fx3    %%    1    0
  2214. X#O op4decay1    num    %%    31    0
  2215. X#O op4attack    num    %%    31    0
  2216. X#O op4level1    num    %%    15    0
  2217. X#O op4decay2    num    %%    31    0
  2218. X#O op4release    num    %%    31    0
  2219. X#O op4wave    txwave    %%    7    0
  2220. X#O op4freq    tf4    %%    878    0
  2221. X#O op4detune    m3num    %%    6    0
  2222. X#O op4outlevel    num    %%    99    0
  2223. X#O op4velocity    num    %%    7    0
  2224. X#O op4ampmod    onoff    %%    1    0
  2225. X#O op4egbias    num    %%    7    0
  2226. X#O op4keyrate    num    %%    3    0
  2227. X#O op4keyscale    num    %%    99    0
  2228. X#O op4egsft    txsft    %%    3    0
  2229. X#O op4fix    fx4    %%    1    0
  2230. X#O feedback    num    %%    7    0
  2231. X#O playmode    mono    %%    1    0
  2232. X#O reverbrate    num    %%    7    0
  2233. X#O transpose    num    %%    45    0
  2234. X#O amoddepth    num    %%    99    0
  2235. X#O fcpitch    num    %%    99    0
  2236. X#O lfospeed    num    %%    99    0
  2237. X#O amodsens    num    %%    3    0
  2238. X#O fcamp    num    %%    99    0
  2239. X#O lfodelay    num    %%    99    0
  2240. X#O pmoddepth    num    %%    99    0
  2241. X#O lfowave    wave    %%    3    0
  2242. X#O pmodsens    num    %%    7    0
  2243. X#O lfosync    onoff    %%    1    0
  2244. X#O modprange    num    %%    99    0
  2245. X#O pitchbend    num    %%    12    0
  2246. X#O modarange    num    %%    99    0
  2247. X#O portatime    num    %%    99    0
  2248. X#O breathprange    num    %%    99    0
  2249. X#O portmode    num    %%    1    0
  2250. X#O breatharange    num    %%    99    0
  2251. X#O autopitch    num    %%    127    -60
  2252. X#O portfoot    onoff    %%    1    0
  2253. X#O breathpbias    num    %%    99    0
  2254. X#O autochan    num    %%    16    -1    *5
  2255. X#O autodur    num    %%    20    -5    *5
  2256. X#O autovol    num    %%    127    -63
  2257. X#O susfoot    onoff    %%    1    0
  2258. X#O breathegbias    num    %%    99    0
  2259. XNULL,NULL,-1,-1,-1,-1,visnum,0,0,0,0
  2260. X};
  2261. X
  2262. X
  2263. Xextern int *txindex;
  2264. Xextern int txleng;
  2265. X
  2266. Xchar *
  2267. Xvistxwave(v)
  2268. X{
  2269. X    static char txbuff[3] = "W ";
  2270. X    txbuff[1] = v + '1';
  2271. X    return(txbuff);
  2272. X}
  2273. X
  2274. Xchar *visfx1(v) { return(visfx(1,v)); }
  2275. Xchar *visfx2(v) { return(visfx(2,v)); }
  2276. Xchar *visfx3(v) { return(visfx(3,v)); }
  2277. Xchar *visfx4(v) { return(visfx(4,v)); }
  2278. X
  2279. Xchar *visfx(n,v)
  2280. X{
  2281. X    static int lastfx[] = { 0, -1, -1, -1, -1 };
  2282. X    char buff2[8];
  2283. X    int fqindex;
  2284. X
  2285. X    if ( lastfx[n] != -1 && lastfx[n] == v )
  2286. X        goto nochange;
  2287. X
  2288. X    lastfx[n] = v;
  2289. X    sprintf(buff2,"op%dfreq",n);
  2290. X    fqindex = parmindex(buff2);
  2291. X    if ( v == 0 )
  2292. X        P[fqindex].p_max = txleng-1;
  2293. X    else
  2294. X        P[fqindex].p_max = 247;
  2295. X    if ( P[fqindex].p_val > P[fqindex].p_max )
  2296. X        P[fqindex].p_val = P[fqindex].p_max;
  2297. X    showparam(fqindex,0);
  2298. Xnochange:
  2299. X    if ( v == 0 )
  2300. X        return("ratio");
  2301. X    else
  2302. X        return("fixed");
  2303. X}
  2304. X
  2305. Xchar *
  2306. Xvistxsft(v)
  2307. X{
  2308. X    switch(v){
  2309. X    case 0: return("off");
  2310. X    case 1: return("48");
  2311. X    case 2: return("24");
  2312. X    case 3: return("12");
  2313. X    }
  2314. X    return("??");
  2315. X}
  2316. X
  2317. Xextern int txfreq[];
  2318. X
  2319. Xchar *
  2320. Xvistxq(v)
  2321. X{
  2322. X    static char fbuff[8];
  2323. X    int f, n1, n2;
  2324. X
  2325. X    txinit();
  2326. X    f = txfreq[txindex[v]];
  2327. X    n1 = f/100;
  2328. X    n2 = f%100;
  2329. X    sprintf(fbuff,n2<10?"%d.0%d":"%d.%d",n1,n2);
  2330. X    return(fbuff);
  2331. X}
  2332. X
  2333. Xchar *
  2334. Xvisfq(v)
  2335. X{
  2336. X    static char fixbuff[8];
  2337. X
  2338. X    sprintf(fixbuff,"%-5d",v+8);
  2339. X    return(fixbuff);
  2340. X}
  2341. X
  2342. Xchar *
  2343. Xvisnfix(n,v)
  2344. X{
  2345. X    char buff[8];
  2346. X    int fx;
  2347. X
  2348. X    sprintf(buff,"op%dfix",n);
  2349. X    fx = getval(buff);
  2350. X    if ( fx == 0 )
  2351. X        return(vistxq(v));
  2352. X    else
  2353. X        return(visfq(v));
  2354. X}
  2355. X
  2356. Xchar *vistf1(v) { return(visnfix(1,v)); }
  2357. Xchar *vistf2(v) { return(visnfix(2,v)); }
  2358. Xchar *vistf3(v) { return(visnfix(3,v)); }
  2359. Xchar *vistf4(v) { return(visnfix(4,v)); }
  2360. END_OF_FILE
  2361. if test 6230 -ne `wc -c <'tx81z.mnu'`; then
  2362.     echo shar: \"'tx81z.mnu'\" unpacked with wrong size!
  2363. fi
  2364. # end of 'tx81z.mnu'
  2365. fi
  2366. if test -f 'unix-mach.c' -a "${1}" != "-c" ; then 
  2367.   echo shar: Will not clobber existing file \"'unix-mach.c'\"
  2368. else
  2369. echo shar: Extracting \"'unix-mach.c'\" \(7945 characters\)
  2370. sed "s/^X//" >'unix-mach.c' <<'END_OF_FILE'
  2371. X# line 1 "unix-mach.c"
  2372. X/* $Id: unix-mach.c,v 1.6 89/05/06 17:13:45 lee Exp $
  2373. X * GLIB - a Generic LIBrarian and editor for synths
  2374. X *
  2375. X * Machine dependent stuff.
  2376. X *
  2377. X * Unix version
  2378. X * Tim Thompson
  2379. X * modifications: Greg Lee
  2380. X * $Log:    unix-mach.c,v $
  2381. X * Revision 1.6  89/05/06  17:13:45  lee
  2382. X * rel. to comp.sources.misc
  2383. X * 
  2384. X */
  2385. X/* LINTLIBRARY */
  2386. X
  2387. X#include "glib.h"
  2388. X#include <ctype.h>
  2389. X
  2390. Xint Rows, Cols;
  2391. X
  2392. X#include <curses.h>
  2393. X
  2394. X/* Ultrix curses fix -- gl */
  2395. X#ifdef ULTRIX
  2396. X#undef nl()
  2397. X#undef nonl()
  2398. X#define nl()    (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
  2399. X#define nonl()    (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
  2400. X#endif
  2401. X
  2402. X#ifdef ARROW
  2403. X#include <sys/ioctl.h>
  2404. X#include <signal.h>
  2405. X#include <setjmp.h>
  2406. Xjmp_buf wakeup;
  2407. X#endif
  2408. X
  2409. X
  2410. X#ifndef ARROW
  2411. X
  2412. Xinitkbd()
  2413. X{}
  2414. X
  2415. Xresetkbd()
  2416. X{}
  2417. X
  2418. Xnmgetch()
  2419. X{
  2420. X    return (getchar() & 0x7f);
  2421. X}
  2422. X
  2423. X#else /*ARROW*/
  2424. X
  2425. X/* Following code for arrow key support lifted from
  2426. X * James Gosling's sc spreadsheet calculator -- gl
  2427. X */
  2428. X#define N_KEY 4
  2429. X
  2430. Xstruct key_map {
  2431. X    char *k_str;
  2432. X    char k_val;
  2433. X    char k_index;
  2434. X}; 
  2435. X
  2436. Xstruct key_map km[N_KEY];
  2437. X
  2438. Xchar keyarea[N_KEY*10];
  2439. X
  2440. Xchar *tgetstr();
  2441. Xchar *getenv();
  2442. X
  2443. X#ifdef TIOCSLTC
  2444. Xstruct ltchars old_chars, new_chars;
  2445. X#endif
  2446. X
  2447. Xchar dont_use[] = {
  2448. X    ctl('z'), ctl('r'), ctl('l'), ctl('b'), ctl('c'), ctl('f'), ctl('g'), ctl('['),
  2449. X    ctl('h'), ctl('m'), ctl('j'), ctl('n'), ctl('p'), ctl('q'), ctl('s'), ctl('t'),
  2450. X    ctl('u'), ctl('v'), ctl('e'), ctl('a'), 0,
  2451. X};
  2452. X
  2453. Xinitkbd()
  2454. X{
  2455. X    register struct key_map *kp;
  2456. X    register i,j;
  2457. X    char *ks;
  2458. X    char *p = keyarea;
  2459. X    static char buf[1024]; /* Why do I have to do this again? */
  2460. X
  2461. X    if (tgetent(buf, getenv("TERM")) <= 0)
  2462. X    return;
  2463. X
  2464. X    km[0].k_str = tgetstr("kl", &p); km[0].k_val = ctl('b');
  2465. X    km[1].k_str = tgetstr("kr", &p); km[1].k_val = ctl('f');
  2466. X    km[2].k_str = tgetstr("ku", &p); km[2].k_val = ctl('p');
  2467. X    km[3].k_str = tgetstr("kd", &p); km[3].k_val = ctl('n');
  2468. X    ks = tgetstr("ks",&p);
  2469. X    if (ks) 
  2470. X    printf("%s",ks);
  2471. X
  2472. X    /* Unmap arrow keys which conflict with our ctl keys   */
  2473. X    /* Ignore unset, longer than length 1, and 1-1 mapped keys */
  2474. X
  2475. X    for (i = 0; i < N_KEY; i++) {
  2476. X    kp = &km[i];
  2477. X    if (kp->k_str && (kp->k_str[1] == 0) && (kp->k_str[0] != kp->k_val))
  2478. X        for (j = 0; dont_use[j] != 0; j++)
  2479. X            if (kp->k_str[0] == dont_use[j]) {
  2480. X             kp->k_str = (char *)0;
  2481. X             break;
  2482. X        }
  2483. X    }
  2484. X
  2485. X
  2486. X#ifdef TIOCSLTC
  2487. X    ioctl(fileno(stdin), TIOCGLTC, (char *)&old_chars);
  2488. X    new_chars = old_chars;
  2489. X    if (old_chars.t_lnextc == ctl('v'))
  2490. X    new_chars.t_lnextc = -1;
  2491. X    if (old_chars.t_rprntc == ctl('r'))
  2492. X    new_chars.t_rprntc = -1;
  2493. X    ioctl(fileno(stdin), TIOCSLTC, (char *)&new_chars);
  2494. X#endif
  2495. X}
  2496. X
  2497. Xresetkbd()
  2498. X{
  2499. X#ifdef TIOCSLTC
  2500. X    ioctl(fileno(stdin), TIOCSLTC, (char *)&old_chars);
  2501. X#endif
  2502. X}
  2503. X
  2504. Xnmgetch() 
  2505. X{
  2506. X    register int c;
  2507. X    register struct key_map *kp;
  2508. X    register struct key_map *biggest;
  2509. X    register int i;
  2510. X    int almost;
  2511. X    int maybe;
  2512. X
  2513. X    static char dumpbuf[10];
  2514. X    static char *dumpindex;
  2515. X
  2516. X    int timeout();
  2517. X
  2518. X    if (dumpindex && *dumpindex)
  2519. X        return (*dumpindex++);
  2520. X
  2521. X    c = getchar() & 0x7f;
  2522. X    biggest = 0;
  2523. X    almost = 0;
  2524. X
  2525. X    for (kp = &km[0]; kp < &km[N_KEY]; kp++) {
  2526. X    if (!kp->k_str)
  2527. X        continue;
  2528. X    if (c == kp->k_str[kp->k_index]) {
  2529. X        almost = 1;
  2530. X        kp->k_index++;
  2531. X        if (kp->k_str[kp->k_index] == 0) {
  2532. X        c = kp->k_val;
  2533. X                   for (kp = &km[0]; kp < &km[N_KEY]; kp++)
  2534. X                kp->k_index = 0;
  2535. X            return(c);
  2536. X        }
  2537. X    }
  2538. X    if (!biggest && kp->k_index)
  2539. X        biggest = kp;
  2540. X        else if (kp->k_index && biggest->k_index < kp->k_index)
  2541. X        biggest = kp;
  2542. X    }
  2543. X
  2544. X    if (almost) { 
  2545. X
  2546. X        (void)signal(SIGALRM, timeout);
  2547. X        alarm(1);
  2548. X
  2549. X    if (setjmp(wakeup) == 0) { 
  2550. X        maybe = nmgetch();
  2551. X        alarm(0);
  2552. X        return(maybe);
  2553. X    }
  2554. X
  2555. X    }
  2556. X    
  2557. X    if (biggest) {
  2558. X    for (i = 0; i<biggest->k_index; i++) 
  2559. X        dumpbuf[i] = biggest->k_str[i];
  2560. X    dumpbuf[i++] = c;
  2561. X    dumpbuf[i] = 0;
  2562. X    dumpindex = &dumpbuf[1];
  2563. X           for (kp = &km[0]; kp < &km[N_KEY]; kp++)
  2564. X        kp->k_index = 0;
  2565. X    return (dumpbuf[0]);
  2566. X    }
  2567. X
  2568. X    return(c);
  2569. X}
  2570. X
  2571. Xtimeout()
  2572. X{
  2573. X    longjmp(wakeup, -1);
  2574. X}
  2575. X
  2576. X#endif /* ARROW */
  2577. X
  2578. Xhello()
  2579. X{
  2580. X}
  2581. X
  2582. Xbye()
  2583. X{
  2584. X    windgoto(22,0);
  2585. X    windrefresh();
  2586. X    resetkbd();
  2587. X    windexit(0);
  2588. X}
  2589. X
  2590. X/* getmouse - get currect row and column of mouse */
  2591. Xgetmouse(amr,amc)
  2592. Xint *amr;
  2593. Xint *amc;
  2594. X{
  2595. X#ifdef USEMOUSE
  2596. X    /* no such */
  2597. X#else
  2598. X    *amr = -1;
  2599. X    *amc = -1;
  2600. X#endif
  2601. X}
  2602. X
  2603. X/* statmouse - return mouse button state (0=nothing pressed,1=left,2=right) */
  2604. Xstatmouse()
  2605. X{
  2606. X#ifdef USEMOUSE
  2607. X    /* no such */
  2608. X#else
  2609. X    return(-1);
  2610. X#endif
  2611. X}
  2612. X
  2613. X/* Return when either a console key or mouse button is pressed. */
  2614. Xmouseorkey()
  2615. X{
  2616. X#ifdef USEMOUSE
  2617. X    /* no such */
  2618. X#else
  2619. X    return(nmgetch());
  2620. X/*
  2621. X    return(getconsole());
  2622. X*/
  2623. X#endif
  2624. X}
  2625. X
  2626. Xflushconsole()
  2627. X{
  2628. X}
  2629. X
  2630. Xstatconsole()
  2631. X{
  2632. X    return(1);
  2633. X}
  2634. X
  2635. Xgetconsole()
  2636. X{
  2637. X    return(getchar());
  2638. X}
  2639. X
  2640. Xint siopenflag = 0;
  2641. XFILE *sifile;
  2642. Xint soopenflag = 0;
  2643. XFILE *sofile;
  2644. Xextern char Syinfname[100];
  2645. Xextern char Syofname[100];
  2646. X
  2647. Xgetmidi()
  2648. X{    int c;
  2649. X
  2650. X    if (!synthinfileflag) return(-1);
  2651. X
  2652. X    if (!siopenflag) {
  2653. X#ifdef BSD
  2654. X        OPENBINFILE(sifile,Syinfname,"r");
  2655. X#else
  2656. X        OPENBINFILE(sifile,Syinfname,"rb");
  2657. X#endif
  2658. X        if (sifile != NULL)
  2659. X            siopenflag = 1;
  2660. X    }
  2661. X    if (siopenflag) {
  2662. X        c = getc(sifile);
  2663. X        if (c == EOF) {
  2664. X            (void)fclose(sifile);
  2665. X            siopenflag = 0;
  2666. X        } else
  2667. X            return(c);
  2668. X    }
  2669. X    return(-1);
  2670. X}
  2671. X
  2672. Xstatmidi()
  2673. X{
  2674. X    if (!synthinfileflag) return(0);
  2675. X    return(1);
  2676. X}
  2677. X
  2678. X/*ARGSUSED*/
  2679. Xsendmidi(c)
  2680. Xint c;
  2681. X{
  2682. X    if (!synthoutfileflag) return;
  2683. X
  2684. X    if (!soopenflag) {
  2685. X#ifdef BSD
  2686. X        OPENBINFILE(sofile,Syofname,"w");
  2687. X#else
  2688. X        OPENBINFILE(sofile,Syofname,"wb");
  2689. X#endif
  2690. X        if (sofile != NULL)
  2691. X            soopenflag = 1;
  2692. X    }
  2693. X    if (soopenflag)
  2694. X        putc(c, sofile);
  2695. X}
  2696. X
  2697. Xflushmidi()
  2698. X{
  2699. X    if (!synthinfileflag && !synthoutfileflag)
  2700. X    while ( STATMIDI )
  2701. X        (void)getmidi();
  2702. X
  2703. X    if (!synthoutfileflag) return;
  2704. X
  2705. X/* To close files used in redirection of midi output, set
  2706. X * synthoutfileflag and call me.
  2707. X */
  2708. X    if (siopenflag) {
  2709. X        (void)fclose(sifile);
  2710. X        siopenflag = 0;
  2711. X    }
  2712. X    if (soopenflag) {
  2713. X        (void)fclose(sofile);
  2714. X        soopenflag = 0;
  2715. X    }
  2716. X}
  2717. X
  2718. Xlong milliclock()
  2719. X{
  2720. X    static long hzcount = 0;
  2721. X
  2722. X    return(hzcount++);
  2723. X}
  2724. X
  2725. Xmillisleep(n)
  2726. X{
  2727. X    sleep((unsigned)((n+500)/1000));
  2728. X}
  2729. X
  2730. Xchar *
  2731. Xalloc(n)
  2732. X{
  2733. X    char *p;
  2734. X
  2735. X    if ( (p=malloc((unsigned)n)) == (char *)NULL ) {
  2736. X        printf("*** Whoops *** alloc has failed?!?  No more memory!\n");
  2737. X        (void)fflush(stdout);
  2738. X        bye();
  2739. X    }
  2740. X    return(p);
  2741. X}
  2742. X
  2743. Xwindinit()
  2744. X{
  2745. X    char *getenv();
  2746. X
  2747. X    initscr();
  2748. X    Cols = 80;
  2749. X    Rows = 24;
  2750. X    noecho();
  2751. X    nonl();
  2752. X#ifdef BSD
  2753. X    crmode();
  2754. X#else
  2755. X    cbreak();
  2756. X#endif
  2757. X    initkbd();
  2758. X}
  2759. X
  2760. Xwindgoto(r,c)
  2761. Xint r,c;
  2762. X{
  2763. X    move(r,c);
  2764. X}
  2765. X
  2766. Xwindeeol()
  2767. X{
  2768. X    clrtoeol();
  2769. X}
  2770. X
  2771. Xwinderaserow(r)
  2772. X{
  2773. X    windgoto(r,0);
  2774. X    windeeol();
  2775. X}
  2776. X
  2777. Xwindexit(r)
  2778. Xint r;
  2779. X{
  2780. X#ifdef BSD
  2781. X    nocrmode();
  2782. X#else
  2783. X    nocbreak();
  2784. X#endif
  2785. X    nl();
  2786. X    echo();
  2787. X    endwin();
  2788. X    (void)exit(r);
  2789. X}
  2790. X
  2791. Xwindclear()
  2792. X{
  2793. X    clear();
  2794. X}
  2795. X
  2796. X/* windgets - get a line of input from the console, handling backspaces */
  2797. Xwindgets(s)
  2798. Xchar *s;
  2799. X{
  2800. X    char *origs = s;
  2801. X    int c;
  2802. X
  2803. X    while ( (c=getconsole()) != '\n' && c!='\r' && c!= EOF ) {
  2804. X        if ( c == '\b' ) {
  2805. X            if ( s > origs ) {
  2806. X                windstr("\b \b");
  2807. X                s--;
  2808. X            }
  2809. X        }
  2810. X        else {
  2811. X            windputc(c);
  2812. X            *s++ = c;
  2813. X        }
  2814. X        windrefresh();
  2815. X    }
  2816. X    *s = '\0';
  2817. X}
  2818. X
  2819. Xwindstr(s)
  2820. Xchar *s;
  2821. X{
  2822. X    int c;
  2823. X
  2824. X    while ( (c=(*s++)) != '\0' )
  2825. X        windputc(c);
  2826. X}
  2827. X
  2828. Xwindputc(c)
  2829. Xint c;
  2830. X{
  2831. X    addch(c);
  2832. X}
  2833. X
  2834. Xwindrefresh()
  2835. X{
  2836. X    refresh();
  2837. X}
  2838. X
  2839. Xbeep()
  2840. X{
  2841. X    putchar('\007');
  2842. X}
  2843. X
  2844. Xwindhigh()
  2845. X{
  2846. X    standout();
  2847. X}
  2848. X
  2849. Xwindnorm()
  2850. X{
  2851. X    standend();
  2852. X}
  2853. X
  2854. X/****************
  2855. X * openls(), nextls(), and closels() are used to scan the current directory.
  2856. X ***************/
  2857. X
  2858. XFILE *Phrlist = NULL;
  2859. X
  2860. Xopenls()
  2861. X{
  2862. X    FILE *popen();
  2863. X    
  2864. X    Phrlist = popen("ls","r");
  2865. X}
  2866. Xchar *
  2867. Xnextls()
  2868. X{
  2869. X    static char fname[65];
  2870. X
  2871. X    if ( fscanf(Phrlist,"%s",fname) != 1 )
  2872. X        return(NULL);
  2873. X    return(fname);
  2874. X}
  2875. Xclosels()
  2876. X{
  2877. X    pclose(Phrlist);
  2878. X}
  2879. X
  2880. X#ifdef FAKECBREAK
  2881. X#include <sys/termio.h>
  2882. Xstruct termio Initterm;
  2883. Xstatic int First = 1;
  2884. Xcbreak()
  2885. X{
  2886. X    struct termio termbuff;
  2887. X
  2888. X    if ( First  ) {
  2889. X        First = 0;
  2890. X        ioctl(0,TCGETA,&Initterm);
  2891. X    }
  2892. X    termbuff = Initterm;
  2893. X    termbuff.c_lflag &= (~ICANON);
  2894. X    termbuff.c_cc[4] = 1;
  2895. X    termbuff.c_cc[5] = 1;
  2896. X    ioctl(0,TCSETA,&termbuff);
  2897. X}
  2898. Xnocbreak()
  2899. X{
  2900. X    ioctl(0,TCSETA,&Initterm);
  2901. X}
  2902. X#endif
  2903. END_OF_FILE
  2904. if test 7945 -ne `wc -c <'unix-mach.c'`; then
  2905.     echo shar: \"'unix-mach.c'\" unpacked with wrong size!
  2906. fi
  2907. # end of 'unix-mach.c'
  2908. fi
  2909. echo shar: End of archive 3 \(of 15\).
  2910. cp /dev/null ark3isdone
  2911. MISSING=""
  2912. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  2913.     if test ! -f ark${I}isdone ; then
  2914.     MISSING="${MISSING} ${I}"
  2915.     fi
  2916. done
  2917. if test "${MISSING}" = "" ; then
  2918.     echo You have unpacked all 15 archives.
  2919.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2920. else
  2921.     echo You still need to unpack the following archives:
  2922.     echo "        " ${MISSING}
  2923. fi
  2924. ##  End of shell archive.
  2925. exit 0
  2926.  
  2927.